https://www.acmicpc.net/problem/6500
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
def sol(s,n):
answer = [s]
while True:
s = str(int(s)**2).zfill(n*2)
s = s[n//2:2*n-n//2]
if s not in answer:
answer.append(s)
else:
return len(answer)
if __name__ == '__main__':
while True:
s = input()
n = 4
if s == '0':
break
print(sol(s,n))
|
cs |
Line 4 : 제곱하고 0 채워넣는 부분
Line 5 : 숫자 중간부분
Line 4 : It means squares number and fill the zero in number
Line 5 : Find middle part of number
반응형
'python-algorithm' 카테고리의 다른 글
백준 9713 Sum of Odd Sequence (0) | 2022.12.06 |
---|---|
백준 26041 비슷한 전화번호 표시 (0) | 2022.12.06 |
백준 7120 String (0) | 2022.12.05 |
백준 6438 Reverse Text (1) | 2022.12.05 |
백준 13234 George Boole (0) | 2022.12.05 |
댓글