백준/기초

[백준][while 문]1110번 더하기 사이클

Snowboarder 2022. 2. 28. 15:04

문제접근

  • while 문 사용하기

문제풀이

내풀이

N = int(input())
compareN = N # compare Number
cnt = 0 # counter

while True:
    A = N//10
    B = N%10
    C = (A+B)%10
    N = (B*10)+C
    cnt += 1
    if N==compareN:
        print(cnt)
        break

다른사람풀이

N = int(input())
n = -1
t = 0
while n != N:
	if n == -1: n = N
	n = (n//10 + n%10)%10 + (n%10)*10
	t += 1
print(t)

숏코딩

a=n=int(input());c=1
while(a:=a%10*10+a*11//10%10)-n:c+=1
print(c)