hdoj 1017
注意格式
1、给的例子有问题,输入N后不用空一行
2、每一组数据输出后面空一行,最后一组数据除外
代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
for (int i = 0; i < N; i++) {
int order = 1;
while (!(sc.hasNext("0") && sc.hasNext("0"))) {
int n = sc.nextInt();
int m = sc.nextInt();
System.out.println("Case " + order + ": " + f(n, m));
order++;
}
int x = sc.nextInt();
int y = sc.nextInt();
if (i != N - 1) {
System.out.println();
}
}
}
private static int f(int n, int m) {
int result = 0;
for (int a = 1; a < n; a++) {
for (int b = a + 1; b < n; b++) {
if ((a * a + b * b + m) % (a * b) == 0) {
result++;
}
}
}
return result;
}
}