Created
May 4, 2015 11:26
-
-
Save rogerioagjr/1a79124ba6c7bd2afe0b to your computer and use it in GitHub Desktop.
Mini-Calculadora - Java
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.util.Scanner; | |
public class solucao { | |
public static int mdc(int a,int b){ | |
int r; | |
while(true){ | |
r = a % b; | |
if(r == 0)break; | |
a = b; | |
b = r; | |
} | |
return b; | |
} | |
public static void main(String[] args){ | |
Scanner in = new Scanner(System.in); | |
int n,a,b; | |
n = in.nextInt(); | |
a = in.nextInt(); | |
b = in.nextInt(); | |
int r = mdc(a,b); | |
a /= r; | |
b /= r; | |
if(n > a && n > b){ | |
System.out.printf("%d %d\n",a,b); | |
} | |
else System.out.println("IMPOSSIVEL\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment