N, M = map(int,input().split()) total_length = N*M so_list = [M]*N cnt = 0 for k in range(N): if so_list[k]%N: cnt += so_list[k]//N else: cnt = cnt + so_list[k]//N-1 so_list[k] -= so_list[k]//N*N if sum(so_list): ind = 0 temp = 0 while ind <N: temp += so_list[ind] if temp == N: temp = 0 elif temp >N: cnt += 1 temp -= N ind += 1 print(cnt)
import functools n,m = map(int,input().split()) @functools.lru_cache() def gdc(n,m): if not n%m: return m return gdc(m,n%m) print(m-gdc(n,m))
'알고리즘 > 백준_복기_미완료' 카테고리의 다른 글
[BOJ/백준] 1722 순열의 순서 (0) | 2021.05.02 |
---|---|
[BOJ/백준] 1405 미친 로봇 (0) | 2021.05.02 |
[BOJ/백준] 1339 단어 수학 (0) | 2021.05.02 |
[BOJ/백준] 1219 오민식의 고민 (0) | 2021.05.02 |
[BOJ/백준] 1202 보석 도둑 (0) | 2021.05.02 |