Posted on 2008-04-06 21:06
superman 阅读(290)
评论(0) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1152 C++ 00:00.32 836K */
2 #include <iostream>
3
4 using namespace std;
5
6 int main()
7 {
8 int N, n, m, Case = 0;
9
10 cin >> N;
11 while(N)
12 {
13 cin >> n >> m;
14 if(n == 0)
15 {
16 N--;
17 Case = 0;
18 if(N)
19 cout << endl;
20 continue;
21 }
22 int count = 0;
23 for(int a = 1; a < n - 1; a++)
24 for(int b = a + 1; b < n; b++)
25 if((a * a + b * b + m) % (a * b) == 0)
26 count++;
27 cout << "Case " << ++Case << ": " << count << endl;
28 }
29
30 return 0;
31 }
32