hdu 1017 A Mathematical Curiosity(水题)

来源:互联网 发布:java员工薪资管理 编辑:程序博客网 时间:2024/06/05 19:26

小记:题意说了输入格式还有输出格式,害的我一直PE了下来,因为样例输入根本就不能提供一点稍有价值的信息,自己摸索着A过来了。


思路:n<100 暴力。注意每个输入块都是从case 1 开始输出。然后不用管是如何输入的,只管输出。输出的结果对于每个输出块后面都要加个空行。最后一行不要加。


代码:

#include <iostream>#include <cstdio>using namespace std;int main(){    //freopen("f:\\out.txt","w",stdout);    int T, n, m,cnt;    cin>>T;    while(T--){        cnt = 1;        while(cin>>n>>m,n||m){            cout<<"Case "<<cnt++<<": ";            int ans = 0;            for(int i = 1; i < n; ++i){                for(int j = i+1; j < n; ++j){                    if((i*i+j*j+m)%(i*j) == 0)ans++;                }            }            cout<<ans<<endl;        }        if(T!=0){            cout<<endl;        }    }    return 0;}


0 0