心如止水
Je n'ai pas le temps
posts - 400,comments - 130,trackbacks - 0
分解质因数。
以下是我的代码:
#include<iostream>
#include
<math.h>
using namespace std;
long max(long a,long b){return (a>b?a:b);}

long Fac(long x)
{
    
long i,re;
    
while(x%2==0)
    {
        re
=2;
        x
/=2;
    }
    i
=3;
    
while(i<=(long)sqrt(x)+1)
        
if(x%i==0)
        {
            re
=i;
            x
/=i;
        }
        
else i+=2;
    
if(x>1) re=x;
    
return re;
}

int main()
{
    
long n,now,ans;
    cin
>>n;
    now
=0;
    
for(long i=1;i<=n;i++)
    {
        
long r,t;
        cin
>>r;
        t
=Fac(r);
        
if(now<t)
        {
            now
=t;
            ans
=r;
        }
    }
    cout
<<ans<<endl;
return 0;
}
posted on 2010-10-18 21:39 lee1r 阅读(340) 评论(0)  编辑 收藏 引用 所属分类: 题目分类:数学/数论

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理