您的位置:首页 > 其它

HDOJ 1017 (水题)

2017-12-03 16:49 176 查看
给定n,m要求满足(x^2+y^2+m)/ab为整数,然后0<a<b<n。求有多少组a,b;n的范围太小了。肯定是个水题没得跑了。
不过要注意下输出形式就是了。


#include <iostream>
using namespace std;
int main(){
ios::sync_with_stdio(false);cin.tie(0);
int N;
cin>>N;
while(N--){
int n,m;
int i = 1;
while(cin>>n>>m){
if(m==0 && n==0) break;
int ans=0;
for(int a = 1;a < n;a ++)
for(int b = a+1;b < n;b ++){
int res=(a*a+b*b+m)%(a*b);
if(res == 0) ans++;
}
cout<<"Case "<<i++<<": "<<ans<<endl;
}
if(N!=0)
cout<<endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  HDOJ-水题