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

27078번 - Wiggle Numbers 다국어

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

문제

The cows are calculating the "life cycle" for each of their identification tag numbers.

Take any positive integer N (1 ≤ N ≤ 9999), say 57, square all the digits and add them up: 5^2 + 7^2 to get 25 + 49 = 74. Now do the same procedure with the result 74 to get the next number in the sequence 65. Continuing to apply this procedure to a sequence of terms eventually repeats one number of the sequence.

When starting with 57, the sequence repeats for the first time with 37, which is the next number in this part of the sequence:

57, 74, 65, 61,

From then on the sequence is trapped in a "life cycle":

37, 58, 89, 145, 42, 20, 4, 16, 37, . . .

If we cube the digits instead of squaring them the sequence has a similar fate. Your job is to write a program that computes how long the sequence lasts until it falls into a life cycle given a starting positive integer and a power P (1 ≤ P ≤ 5).

입력

A single line with a single positive integer no longer than 75 digits.

출력

A single integer that is the number of initial digits of the number that form a wiggle number.

제한

예제 입력 1

3748

예제 출력 1

4

힌트

출처

Olympiad > USA Computing Olympiad > 2001-2002 Season > USACO US Open 2002 Contest > Orange 1번

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

출처

대학교 대회

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

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