UVA11970 Lucky Numbers【数列】

Every person has its own numbers that he considers lucky. Usually the numbers are fixed like 3 or 7 and do not depend on anything. This lucky number model seems to be very primitive for John, so he decided to upgrade it for his own use. Maybe more complex model will bring more luck to him?
    John has added a dependency for lucky numbers on specific integer N (for example N can be ordinal number of day in year or some other meaning). For each N John considers some number X lucky if and only if fraction X/√(N − X) value is integer and greater than zero.
Input
The number of tests T (T ≤ 100) is given on the first line. T lines follow, each of them contains one integer N (1 ≤ N ≤ 10^9) described above.
Output
For each test case output a single line ‘Case T: S’. Where T is the test case number (starting from 1) and S is increasing sequence of numbers considered lucky by John for specified N. Please refer to the sample output for clarity.
Sample Input
3
16
109
33
Sample Output
Case 1: 12 15
Case 2: 108
Case 3: 24 32

问题链接:UVA11970 Lucky Numbers
问题简述:(略)
问题分析
    数列有关的数学题,不解释。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA11970 Lucky Numbers */

#include 

using namespace std;

int main()
{
    int t;
    scanf("%d", &t);
    for(int k = 1; k <= t; k++) {
        printf("Case %d:", k);

        long long n;
        scanf("%lld", &n);
        for(long long j = sqrt(n); j >0; j--) {
            long long t = n - j * j;
            if(t % j == 0 && t > 0)
                printf(" %lld", t);
        }
        printf("\n");
    }

    return 0;
}

你可能感兴趣的:(#,ICPC-备用二,#,ICPC-数列,#,ICPC-UVA)