-
-
Save folivetti/0b650349612ec15b42b164be5506c369 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.util.Scanner; | |
public class Main { | |
public static int gcd (int x, int y) { | |
int r = x%y; | |
while (r!=0) { | |
x = y; | |
y = r; | |
r = x%y; | |
} | |
return y; | |
} | |
public static int gcd3(int x, int y, int z) { | |
return gcd(x, gcd(y,z)); | |
} | |
public static void main(String[] args) throws IOException { | |
int x, y, z, tmp; | |
String linha; | |
Scanner leitor = new Scanner(System.in); | |
while (leitor.hasNextLine()) { | |
linha = leitor.nextLine(); | |
if (linha == null) break; | |
Scanner sc = new Scanner(linha); | |
x = sc.nextInt(); | |
y = sc.nextInt(); | |
z = sc.nextInt(); | |
// x tem o maior valor | |
if (y > x && y >= z) { | |
tmp = x; | |
x = y; | |
y = tmp; | |
} else if (z > x && z > y) { | |
tmp = x; | |
x = z; | |
z = tmp; | |
} | |
System.out.print("tripla"); | |
if (x*x == (y*y + z*z)) { | |
System.out.print(" pitagorica"); | |
if (gcd3(x,y,z) == 1) { | |
System.out.print(" primitiva"); | |
} | |
} | |
System.out.println(""); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment