프로그래밍/Baekjoon
(파이썬) 백준 알고리즘 1110번
J_Remind
2018. 12. 2. 16:36
문제
풀이 (Python)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | n = input() if int(n) < 10: n = n + '0' cnt = 0 sum = 0 tmp = n while True: cnt += 1 sum = int(tmp[0]) + int(tmp[1]) if sum < 10: new = tmp[1]+str(sum) else : new = tmp[1] + str(sum)[1] if new == n: break else: tmp = new print (cnt) | cs |