Logo
(追記) (追記ここまで)

27037번 - The Middle Squares 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB174787245.000%

문제

Bessie's daghter, Cassie, returned from calf school with a new math problem. "I'm not sure I can do all the arithmetic," she whined.

"What is it you're doing?" asked her concerned mother.

"We are given a positive integer N less than 10,000," Cassie replied. "We treat it as four digit number, even if it's like 12 or something. We extract the second and third digits to create a new number which we then square to create another four digit number. We repeat that until we get to some number that we have already seen."

Help poor Cassie with her homework. Here is an example that starts with the number 4444:

 N 2nd&3rd Squared
4444 ... 0044 ... 1936
1936 ... 0093 ... 8649
8649 ... 0064 ... 4096
4096 ... 0009 ... 0081
0081 ... 0008 ... 0064
0064 ... 0006 ... 0036
0036 ... 0003 ... 0009
0009 ... 0000 ... 0000
0000 ... 0000 ... 0000

This example required nine iterations to complete. The number 0000 results in a loop, since its resulting middle square is also 0000.

입력

  • Line 1: A single integer, N

출력

  • Line 1: A single integer that is the number of iterations before some number is duplicated.

제한

예제 입력 1

4444

예제 출력 1

9

힌트

출처

Olympiad > USA Computing Olympiad > 2003-2004 Season > USACO February 2004 Contest > Blue 4번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /