### Singleton difference题号：136 难度： 50 中英对照

The positive integers, x, y, and z, are consecutive terms of an arithmetic progression. Given that n is a positive integer, the equation, x2y2z2 = n, has exactly one solution when n = 20:

132 − 102 − 72 = 20

In fact there are twenty-five values of n below one hundred for which the equation has a unique solution.

How many values of n less than fifty million have exactly one solution?

### Code

public final class p135 {
public static void main(String[] args) {
long start=System.nanoTime();
String result = run();
long end=System.nanoTime();
System.out.println(result);
System.out.println( (end-start)/1000000 + "ms" );
}

static public String run(){
final int LIMIT=50000000;
int[] solutions = new int[LIMIT];
for (int m = 1; m < LIMIT * 2; m++) {
for (int k = m / 5 + 1; k * 2 < m; k++) {
long temp = (long)(m - k) * (k * 5 - m);
if (temp >= solutions.length)
break;
solutions[(int)temp]++;
}
}

int count = 0;
for (int x : solutions) {
if (x == 1)
count++;
}
return Integer.toString(count);
}

}
2544559
2883ms