zju 1152 A Mathematical Curiosity
代码:
#include<cstdio> #include<cstdlib> #include<cmath> int main() { int n,m,tcase,k,i,j,a,b,m_count; while(scanf("%d",&tcase)==1) { for(i=0;i<tcase;i++) { if(i) printf("\n"); k=1; while(scanf("%d%d",&n,&m)&&(n||m)) { m_count=0; for(a=1;a<n;a++) for(b=a+1;b<n;b++) { if((a*a+b*b+m)%(a*b)==0) { m_count++; } } printf("Case %d: %d\n",k++,m_count); } } } }