Skip to content

Instantly share code, notes, and snippets.

@Jueast
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jueast/7b531e786d7fc3e2ce34 to your computer and use it in GitHub Desktop.
Save Jueast/7b531e786d7fc3e2ce34 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int k;
int main(void){
int x;
scanf("%d%d",&k,&x);
if (judge(x))
printf("YES.\n");
else
printf("NO.\n");
return 0;
}
int judge(int x){
if (x == k)
return 1;
if (x > k){
if ((x-1)%3==0 && (x-1)%2==0)
return(judge((x-1)/2)||judge((x-1)/3));
if ((x-1)%3==0)
return(judge((x-1)/3));
if ((x-1)%2==0)
return(judge((x-1)/2));}
else
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment