提示: 欢迎访问OurACM平台。
Problem 1871 Amicable Pair

Accept: 67    Submit: 198
Time Limit: 1000 mSec    Memory Limit : 32768 KB

Problem Description

An amicable pair (m,n) consists of two integers m,n for which the sum of proper divisors (the divisors excluding the number itself) of one number equals the other. Amicable pairs are occasionally called friendly pairs (Hoffman 1998, p. 45), although this nomenclature is to be discouraged since the numbers more commonly known as friendly pairs are defined by a different, albeit related, criterion. Symbolically, amicable pairs satisfy

where
is the restricted divisor function. Equivalently, an amicable pair (m,n) satisfies
where is the divisor function. The smallest amicable pair is (220, 284) which has factorizations
giving restricted divisor functions
The quantity
in this case, 220+284=504, is called the pair sum. The first few amicable pairs are (220, 284), (1184, 1210), (2620, 2924) (5020, 5564), (6232, 6368), (10744, 10856), (12285, 14595), (17296, 18416), (63020, 76084), ... (Sloane's A002025 and A002046). An exhaustive tabulation is maintained by D. Moews. (from http://mathworld.wolfram.com/AmicablePair.html )

Now give you a interval [A,B],(0 < A <= B <= 10^7),your task is to find out all amicable pair ( A <= m < n <= B).

Input

There are multiply test cases. For each test case ,just one line ,two numbers A and B, separate by space.

Output

For each test case , first output the total number of amicable pair (m,n) which satisfy ( A <= m < n <= B), then output the amicable pair each line by ascending order(sort by the value of m).

Sample Input

220 1210

Sample Output

2 220 284 1184 1210

Source

iyixiang

Submit  Back  Status  Discuss