Skip to content

Instantly share code, notes, and snippets.

@Jack-Saleem
Created July 17, 2016 13:55
Show Gist options
  • Save Jack-Saleem/0c0dc829250109a5cde367d9ceb0a97d to your computer and use it in GitHub Desktop.
Save Jack-Saleem/0c0dc829250109a5cde367d9ceb0a97d to your computer and use it in GitHub Desktop.
codeforces 199A HexadecimalsTheorem program in java
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