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

문제

The numbers 220 and 284 are called Amicable Numbers because they are not equal, and for each, the sum of its divisors equals the other number. That is, the sum of the divisors of 220,

1 + 2 + 4 + 5 + 10 + 11 + 20 + 22 + 44 + 55 + 110 equals 284,

and the sum of the divisors of 284,

1 + 2 + 4 + 71 + 142 equals 220.

Produce a program that takes in a natural number and finds the pairs of Amicable Numbers up to and including the given value. 

입력

The input is a series of lines, each with a single number N. 0 < N ≤ 106. Input is terminated by a line with the value 0. 

출력

For each input number N, output a blank line, then a line with the text ‘Amicable numbers between 1 and N. Follow that with a line for each distinct amicable pair discovered, giving the pair of numbers, separated with a space. Amicable pair should be output with the lesser of the two numbers displayed first. Pairs should be in ascending order of their lesser values. If there are no amicable pairs, display ‘None’. Note: A number cannot form an amicable pair with itself. 

예제 입력 1

100
300
0

예제 출력 1

Amicable numbers between 1 and 100
None

Amicable numbers between 1 and 300
220 284

출처

ICPC > Regionals > South Pacific > South Pacific Region > New Zealand Programming Contest > NZPC 2009 I번

  • 문제의 오타를 찾은 사람: doju
  • 잘못된 데이터를 찾은 사람: dotorya