friend numbers = 2^x + 3^y -1
1 #include<stdio.h> 2 int main() 3 { 4 __int64 a; 5 while(scanf("%I64d",&a)!=EOF) 6 { 7 if(!a) 8 { 9 printf("NO! "); 10 continue; 11 } 12 a+=1; 13 while(a%2==0||a%3==0) 14 { 15 if(a%2==0) a/=2; 16 if(a%3==0) a/=3; 17 } 18 if(a==1) printf("YES! "); 19 else printf("NO! "); 20 } 21 }