HDOJ1017 A Mathematical Curiosity

原题链接

注意输出格式,每一组的case都要重新开始计数。

//模拟
//2014-3-11 08:19:16
#include <stdio.h>

int main(){
    int t, n, m, a, b, count, time;
    scanf("%d", &t);
    while(t--){
		time = 1;
        while(scanf("%d%d", &n, &m), n || m){
            for(a = 1, count = 0; a < n - 1; ++a)
                for(b = a + 1; b < n; ++b)
                    if((a*a + b*b + m) % (a * b) == 0)
                        ++count;
            printf("Case %d: %d\n", time++, count);
        }
        if(t) printf("\n");
    }
    return 0;
}


posted on 2014-03-11 08:51  长木Qiu  阅读(125)  评论(0编辑  收藏  举报