hdoj-1017-A Mathematical Curiosity(格式坑)

题目链接

/*
    Name:
    Copyright:
    Author:
    Date: 2018/5/3 16:32:15
    Description:
*/
#include <iostream>
#include <cstdio>
using namespace std;
int n, m;
bool equals(int a, int b) {
    if ((a*a+b*b+m) % (a*b) == 0)return true;
    return false;
}
int main()
{
    int t;
    cin>>t;
    while (t--) {
        int tag = 0;
        while (cin>>n>>m) {
            if ((n+m) == 0) break;
            int ct = 0;
            for (int i=1; i<n; i++) {
                for (int j=i+1; j<n; j++) {
                    if (i == j) continue;
                    if (equals(i, j)) {
                        ct++;
                    }
                }
            }
            printf("Case %d: %d\n", ++tag, ct);
        }
        if (t >= 1) printf("\n");//换行 
    }
    return 0;
}

 

posted @ 2018-05-03 16:56  朤尧  阅读(233)  评论(0编辑  收藏  举报