数论题目小结 #by nobody

本小结会不断更新,转载注明出处: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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值