Created
July 17, 2016 13:55
-
-
Save Jack-Saleem/0c0dc829250109a5cde367d9ceb0a97d to your computer and use it in GitHub Desktop.
codeforces 199A HexadecimalsTheorem program in java
This file contains hidden or 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 HexadecimalsTheorem | |
{ | |
public static void main(String[] args) | |
{ | |
Scanner z=new Scanner(System.in); | |
int n=z.nextInt(); | |
if(n==0) | |
System.out.println("0"+" 0 "+"0"); | |
else if(n==1) | |
System.out.println("0"+" 0 "+"1"); | |
else if( n==2) | |
System.out.println("0"+" 1 "+"1"); | |
else if(n==3) | |
System.out.println("1"+" 1 "+"1"); | |
else if(n==5) | |
System.out.println("1"+" 1 "+"3"); | |
else{ | |
int a=0; | |
int b=1; | |
int c=1; | |
int d=2; | |
int e=3; | |
while(true){ | |
c=a+b; | |
if(c==n){ | |
System.out.println(b+" "+e+" "+d); | |
break; | |
} | |
d=b+c; | |
if(d==n){ | |
System.out.println(c+" "+a+" "+e); | |
break; | |
} | |
e=c+d; | |
if(e==n){ | |
System.out.println(d+" "+a+" "+b); | |
break; | |
} | |
a=d+e; | |
if(a==n){ | |
System.out.println(e+" "+b+" "+c); | |
break; | |
} | |
b=e+a; | |
if(b==n){ | |
System.out.println(a+" "+c+" "+d); | |
break; | |
} | |
} | |
} | |
z.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment