HUD1017
来源:互联网 发布:阿里云如何做代理商 编辑:程序博客网 时间:2024/06/02 05:30
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1017
没什么好说的,直接循环遍历,记录可行情况
要注意的是最后一种情况输出时没有换行!
#include<iostream>int deal(int n,int m){ int count=0; int res; for(int a=1;a<n;a++) { for(int b=a+1;b<n;b++) { res=(a*a+b*b+m)%(a*b); if(!res) count+=1; } } return count;}int main(){ int N,n,m; scanf("%d",&N); while(N--) { int ca=0; while(scanf("%d%d",&n,&m),n||m) { printf("Case %d: %d\n",++ca,deal(n,m)); } if(N) printf("\n"); } return 0;}
0 0