### Right-angled triangles that share a cathetus题号：176 难度： 70 中英对照

The four right-angled triangles with sides (9,12,15), (12,16,20), (5,12,13) and (12,35,37) all have one of the shorter sides (catheti) equal to 12. It can be shown that no other integer sided right-angled triangle exists with one of the catheti equal to 12.

Find the smallest integer that can be the length of a cathetus of exactly 47547 different integer sided right-angled triangles.

### Code

import java.util.ArrayList;

public final class p176 {
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 final int prime[]=new int[]{2,3,5,7,11,13,17,19,23};

static public String run() {
final long x=47547;
return ""+solve(x);
}

static long solve(long x){
long d=x*2+1;
ArrayList<Integer> ps=new ArrayList<Integer>();
long tmp=d;
for(int i=0;i<prime.length;i++){
if(tmp%prime[i]==0)
}
long num=1;
for(int i=0;i<ps.size()&&i<prime.length;i++){
for(int j=0;j<ps.get(i);j++)
num*=prime[ps.size()-1-i];
}
return num*2;
}

}
96818198400000
0ms