/* x=a+b+ab=(a+1)(b+1)-1 x=x1+x2+x1*x2=(a1+1)(b1+1)(a2+1)(b2+1)-1 x+1=(a+1)^x(b+1)^y; a=1,b=2或b=1,a=2 a=b=1,a=b=2 x+1=2^x*3^y */ #include <stdio.h> int main() { int n; while(scanf("%d",&n)!=EOF) { if(n==0) { printf("NO!\n"); continue; } n++; while(n%2==0||n%3==0) { if(n%2==0) n/=2; if(n%3==0) n/=3; } if(n==1) printf("YES!\n"); else printf("NO!\n"); } return 0; }
hdu1719 Friend
最新推荐文章于 2022-04-05 20:10:57 发布