수학적 패턴에 대해서 추가적으로 공부했다. 1011번인 Fly me to the Alpha Centauri 문제가 Gold단계 문제였었다. 패턴을 찾는데 꽤나 고생했다. 그래도 어느정도 감을 잡은 느낌이 들어서 만족스러웠다. 계속 연습해나갈 예정이다.
백준 2775번 부녀회장이 될테야
T = int(input())
for i in range(T):
floor = int(input())
ho = int(input())
f0 = [i for i in range(1,ho+1)] #list comprehension
for j in range(floor):
for i in range(1,ho):
f0[i] += f0[i-1]
print(f0[-1])
백준 2839번 설탕 배달
N = int(input())
count = 0
while N>=0:
if N%5==0:
count += (N//5)
print(count)
break
N -= 3
count += 1
else:
print(-1)
# 처음에 문제를 잘못 이해했다. 5kg,3kg으로 정확히 나누어 떨어져야함
백준 10757번 큰 수 A+B
A,B = map(int,input().split())
print(A+B)
# 파이썬은 큰 값도 상관없다
백준 1011번 Fly me to the Alpha Centauri
import math
T = int(input())
for i in range(T):
x,y = map(int,input().split())
togo = y-x
count = 0
num = math.floor(math.sqrt(togo)) # root 및 내림
if togo<4:
count = togo
elif togo>num**2+num:
count = 2*num+1
elif num**2<togo<=num**2+num:
count = 2*num
elif togo == num**2:
count = 2*num-1
print(count)
'''
togo count
1 1 1
2 2 11
3 3 111
4 3 121 root4까지 갔다옴 ) -1~0까지 count3, 1~2까지 count4, 3~4까지 count5
5 4 1211
6 4 1221
7 5 12211
8 5 12221
9 5 12321 root9까지 갔다옴 ) -1~0까지 count5, 1~3까지 count6,4~5까지 count7
10 6 123211
11 6 123221
12 6 123321
13 7 1233211
14 7 1233221
15 7 1233321
16 7 1234321 root16까지 갔다옴 )-1~0까지 count7, 1~4까지 count8,5~6까지 count9
'''
# 규칙성 찾는 것이 중요했다