ummm,这题目好烦人....看半天根本读不懂.....然后发现....有点水....
然后竟然没有AC
.........
发现了没有AC的地方,case n 不是一直自增的,每次for 结束会变....下列代码已经修改,是AC的
# include<iostream>
using namespace std;
void out(int n,int count) {
cout << "Case " << n << ": " << count << endl;
}
int main(void) {
//integers (a,b) 暗示整形
// 0 < a < b < n 暗示 a 外围0-n,b=a+1
// 判定式 (a^2+b^2 +m)/(ab) is an integer.
int N;
int n, m;// that 0 < n <= 100.
int a, b;
int count = 0;
int Out_n;
cin >> N;
for (int index = 0; index < N; ++index) {
Out_n = 1;
cin >> n >> m;
while (n || m) {
for (a = 1; a < n; ++a) {
for (b = a + 1; b < n; ++b) {
if (!((a*a + b*b + m) % (a*b)))
count++;
}
}
out(Out_n,count);
Out_n++;
count = 0;//count 清零
cin >> n >> m;
}
if (index != N - 1)
cout << endl;
}
system("pause");
return 0;
}