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

4784번 - Unhappy Numbers 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB131171422.581%

문제

Numbers have feelings too! For any positive integer, take the sum of the squares of each of its digits, and add them together. Take the result, and do it again. A number is Happy if, after repeating this process a finite number of times, the sum is 1. Some happy numbers take more iterations of this process to get to 1 than others, and that would be referred to as its distance from happiness. 1’s distance from happiness is 0. 23’s distance from happiness is 3, since 22 + 32 = 13, 12 + 32 = 10, and 12 + 02 = 1. Numbers are Unhappy if they are infinitely far away from happiness because they get stuck in a loop.

Given the lower end and upper end of a range of integers, determine how many Unhappy numbers are in that range (inclusive).

입력

There will be several test cases in the input. Each test case will consist of two positive integers, lo and hi (0<lo≤hi≤1018) on a single line, with a single space between them. Input will terminate with two 0s.

출력

For each test case, output a single integer on its own line, indicating the count of Unhappy Numbers between lo and hi (inclusive). Output no extra spaces, and do not separate answers with blank lines.

제한

예제 입력 1

1 10
1 100
0 0

예제 출력 1

7
80

힌트

출처

ICPC > Regionals > North America > Southeast USA Regional > 2012 Southeast USA Regional Programming Contest > Division 1 I번

ICPC > Regionals > North America > Southeast USA Regional > 2012 Southeast USA Regional Programming Contest > Division 2 I번

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

출처

대학교 대회

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

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