设为首页 加入收藏

TOP

Acdreamoj1115(数学思维题)
2015-07-24 06:13:07 来源: 作者: 【 】 浏览:30
Tags:Acdreamoj1115 数学 思维

题意:1,3是完美数,如果a,b是完美数,则2+a*b+2*a+2*b,判断给出的n是否是完美数。


解法:开始只看出来2+a*b+2*a+2*b=(a+2)*(b+2)-2,没推出更多结论,?。没办法,只能暴力将所有的完美数求出来然后查表。正解是c+2=(a+2)*(b+2);完美数都是有质因子3或5组成的(5本身除外);


自己暴力代码:

/******************************************************
* author:xiefubao
*******************************************************/
#pragma comment(linker, "/STACK:102400000,102400000")
#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        #include 
       
         #include 
        
          #include 
         
           #include 
           #include 
           
             #include 
            
              #include 
             
               //freopen ("in.txt" , "r" , stdin); using namespace std; #define eps 1e-8 #define zero(_) (abs(_)<=eps) const double pi=acos(-1.0); typedef long long LL; const int Max=1010; const int INF=1000000000; LL num[Max]; int help[Max]; LL get(int l,int r) { return 2*(num[l]+1)*(num[r]+1)-num[l]*num[r]; } struct point { LL ans; int h; }; bool operator<(const point& a,const point& b) { return a.ans>b.ans; } priority_queue
              
                pri; int main() { num[0]=1; num[1]=3; point p; p.ans=7; p.h=0; pri.push(p); p.ans=23; p.h=1; pri.push(p); for(int i=0; i
               
                

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇LeetCode――Symmetric Tree 下一篇poj 3150 Cellular Automaton(矩..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: