@Darklordx/

# TEMPLATE-39

## No description

Files
• Main.java
Main.java
```1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
```
```//TEMPLATE
import java.util.*;
import java.math.*;
public class Main {
static Scanner scan;
public static void println(Object s){System.out.println(s);}
public static void print(Object s){System.out.print(s);}
public static int nextInt(){return scan.nextInt();}
public static long nextLong(){return scan.nextLong();}

public static int nextIntL(){int i = scan.nextInt(); scan.nextLine(); return i;}
public static long nextLongL(){long i = scan.nextLong(); scan.nextLine(); return i;}

public static String nextLine(){return scan.nextLine();}

static void printArray(int arr[])
{
int n = arr.length;
for (int i=0; i<n; ++i)
System.out.print(arr[i]+" ");
System.out.println();
}

public static void main(String[] args) {scan = new Scanner(System.in);solution();}

//Solution goes below:
public static void solution(){
Stack<Integer> stack = new Stack<Integer>();
//Initialization
stack.push(2);
stack.push(1);
int m,n;
int[] tri;

int count = 0;

while(!stack.isEmpty()){
n = stack.pop();
m = stack.pop();
if(m*(m+n)<50000000){
tri = genTri(m,n);
if(tri[2]%(tri[1]-tri[0])==0){
print("Sides: ");
printArray(tri);
print("Perimeter: ");
println(2*m*(m+n));
print("Number:");
println(50000000/m/(m+n));
count+=50000000/m/(m+n);
}

stack.push(2*m-n); stack.push(m);
stack.push(2*m+n); stack.push(m);
stack.push(m+2*n); stack.push(n);
}
}
print("Count: ");
println(count);
}
public static int[] genTri(int m, int n){
return new int[] {2*m*n, m*m-n*n, m*m+n*n};
}
}```
Fetching token