HDU1719 Friend (数学推导)

时间:2014-04-30 01:43:36   收藏:0   阅读:322

friend numbers = 2^x + 3^y -1

mamicode.com,码迷
 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!\n");
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!\n");
19         else printf("NO!\n");                      
20     }    
21 }
mamicode.com,码迷

 

HDU1719 Friend (数学推导),码迷,mamicode.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!