// [10/7/2013 qingezha] Find 1... The number of all affinity between n. // The So-called affinity number, that is, there is a number a and B, the sum of all the true factors of a is equal to B, and the sum of all the true factors of B is equal to a, it is called a and B as a pair of affinity. // For example, the true factor of 220 is: 1, 2, 4, 5, 10, 11, 20, 22, 44, 55, 110, and 284, and the true factor of 284 is: 1, 2, 4, 71, 142, and positive ratio: 220. Therefore, 220 and 284 are a pair of affinity numbers. // If the true factor of j is set to sum [j], then j can be divisible by all the factors and sum [j]. The possible division is the key void print_Affsum (int n) {if (n <= 0) return; int * sum = new int [n + 1]; for (int I = 1; I <n + 1; ++ I) sum [I] = 1; // All affinity numbers have the factor 1for (int I = 2; I <n/2; ++ I) // I as the factor, therefore, the maximum value can only be n/2 {for (int j = 2 * I; j <n + 1; j + = I). // j indicates that I can be divisible, so the increment is I {sum [j] + = I;} int I = 1; while (I <n + 1) {if (sum [I] <n + 1 & I = sum [sum [I]) // do not forget to check the value of sum [I, because sum [sum [I] may cross-border cout <I <"" <sum [I] <endl; ++ I;} delete [] sum ;}