数论题目小结 #by nobody

来源:互联网 发布:双十一对淘宝的意义 编辑:程序博客网 时间:2024/05/21 14:56

本小结会不断更新,转载注明出处: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模板题,,需要模板可以去看我的

http://blog.csdn.net/xdu_truth/article/details/8042161

原创粉丝点击