python-algorithm
백준 3060 욕심쟁이 돼지
무적김두칠
2022. 11. 30. 12:55
https://www.acmicpc.net/problem/3060
3060번: 욕심쟁이 돼지
입력은 T개의 테스트 데이터로 구성된다. 입력의 첫 번째 줄에는 입력 데이터의 수를 나타내는 정수 T가 주어진다. 각 테스트 데이터는 두 줄로 구성되어 있고, 첫째 줄에는 하루에 배달되는 사
www.acmicpc.net
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
def sol(food, pigs):
total_sum =sum(pigs)
days = 1
while food>=total_sum:
total_sum+=total_sum*3
days+=1
return days
if __name__ == '__main__':
n=int(input())
for i in range(n):
food = int(input())
pigs = list(map(int, input().split()))
print(sol(food,pigs))
|
cs |
양 옆과 맞은편을 더한다는 말은 결국 총 합의 3배가 된다는 뜻이죵
Adding the sides and the opposite side means that the total sum is three times
반응형