您的位置:首页 > 其它

数论题目小结 #by nobody

2012-10-06 13:38 316 查看
本小结会不断更新,转载注明出处:http://blog.csdn.net/xdu_truth/article/details/8043051

pku2689 Prime Distance

其实这个题的突破口在于U-L<=1000000,自然想到筛法。先找出sqrt(2^32)内的所有素数,然后类似筛选法筛选掉[l,u]范围内的数

ZOJ 2562 //反素数

题意:找出不大于n因子最多的最小的数。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
LL p[15] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43};
LL ans = 0,ansnum = 0;

void back_prime(LL now,int d,LL num,LL n)
{
if(d>=14)return;
if(num>ansnum){ansnum = num;ans = now;}
else if(num==ansnum){ans = min(ans,now);}
LL temp = 1LL;
for(int i=0;i<=53;i++)
{
temp *= p[d];
if(now*temp > n)break;
back_prime(now*temp,d+1,num*((LL)i+2LL),n);
}
}
int main()
{
LL n;
while(cin >> n)
{
ans = 0,ansnum = 0;
back_prime(1LL,0,1LL,n);
cout << ans << endl;
}
return 0;
}


poj 1811

裸的miller_rabin和pollard模板题,,需要模板可以去看我的

/article/9825886.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: