题目大意:
求出最小的正整数,它的约数有$2^{500500}$个。

思路:
考虑将一个数质因数分解,如果它的约数有$2^{500500}$个, 那么每个质因子的指数一定是$2^k-1$这样的形式。

如果把质因子$p$的指数从$2^k-1$增大到$2^{k+1}-1$ 那么相当于在原数的基础上乘以$p^{2^k}$.

所以就可以贪心了, 一开始把足够多的质数放进小根堆里,然后每次取出最小的$x$, 把答案乘上$x$, 然后把$x^2$ 加入堆里。

代码:

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <set>
#include <cstring>
#include <map>
#include <queue>
using namespace std; typedef long long ll;
#define N 10000000
#define M 1100
typedef pair<int,int> pii; bool flag[N];
int p[N],phi[N]; void Get_Primes()
{
phi[]=;
for (int i=;i<N;i++)
{
if (!flag[i]) p[++p[]]=i,phi[i]=i-;
for (int j=;j<=p[] && i*p[j]<N;j++)
{
flag[i*p[j]]=true;
if (i%p[j]==)
{
phi[i*p[j]]=phi[i]*p[j];
break;
}
else phi[i*p[j]]=phi[i]*(p[j]-);
}
}
} priority_queue<ll, vector<ll>, greater<ll> > Q; int main()
{
freopen("in.in","r",stdin);
freopen("out.out","w",stdout); ll ans = , mod = ;
Get_Primes();
for (int i = ; i <= ; ++i) Q.push(p[i]);
for (int i = ; i <= ; ++i)
{
ll x = Q.top();
ans = x % mod;
Q.pop(), Q.push(x * x);
}
cout << ans << endl;
return ;
}

答案:35407281

Problem 500!!! (Project Euler 500)的更多相关文章

  1. Problem 43 // Project Euler

    Sub-string divisibility The number, 1406357289, is a 0 to 9 pandigital number because it is made up ...

  2. Python练习题 040:Project Euler 012:有超过500个因子的三角形数

    本题来自 Project Euler 第12题:https://projecteuler.net/problem=12 # Project Euler: Problem 12: Highly divi ...

  3. Python练习题 037:Project Euler 009:毕达哥拉斯三元组之乘积

    本题来自 Project Euler 第9题:https://projecteuler.net/problem=9 # Project Euler: Problem 9: Special Pythag ...

  4. Python练习题 049:Project Euler 022:姓名分值

    本题来自 Project Euler 第22题:https://projecteuler.net/problem=22 ''' Project Euler: Problem 22: Names sco ...

  5. Python练习题 048:Project Euler 021:10000以内所有亲和数之和

    本题来自 Project Euler 第21题:https://projecteuler.net/problem=21 ''' Project Euler: Problem 21: Amicable ...

  6. Python练习题 047:Project Euler 020:阶乘结果各数字之和

    本题来自 Project Euler 第20题:https://projecteuler.net/problem=20 ''' Project Euler: Problem 20: Factorial ...

  7. Python练习题 045:Project Euler 017:数字英文表达的字符数累加

    本题来自 Project Euler 第17题:https://projecteuler.net/problem=17 ''' Project Euler 17: Number letter coun ...

  8. Python练习题 044:Project Euler 016:乘方结果各个数值之和

    本题来自 Project Euler 第16题:https://projecteuler.net/problem=16 ''' Project Euler 16: Power digit sum 2* ...

  9. Python练习题 043:Project Euler 015:方格路径

    本题来自 Project Euler 第15题:https://projecteuler.net/problem=15 ''' Project Euler: Problem 15: Lattice p ...

随机推荐

  1. mac 下安装 mysql (蛋疼)

    mac先安装mydql步骤 1.首先从官网上下载 mac版本的mysql:我的是mysql-5.7.20-macos10.12-x86_64.dmg 2.正常安装: 3.在系统偏好设置的最底下.1:是 ...

  2. 设计工作-Axure

    1,百度百科 http://baike.baidu.com/view/3332366.htm?fromtitle=axure&fromid=5056136&type=syn 2,官方网 ...

  3. [Python爬虫] 之二十六:Selenium +phantomjs 利用 pyquery抓取智能电视网站图片信息

    一.介绍 本例子用Selenium +phantomjs爬取智能电视网站(http://www.tvhome.com/news/)的资讯信息,输入给定关键字抓取图片信息. 给定关键字:数字:融合:电视 ...

  4. 【枚举】【SDOI 2011】【bzoj 2241】打地鼠

    2241: [SDOI2011]打地鼠 Time Limit: 10 Sec Memory Limit: 512 MB Submit: 877 Solved: 557 Description 打地鼠是 ...

  5. android源代码下载备注

    android源代码下载的參考网上比較多,就不贴上来了,主要是备注下下载源代码过程中须要注意的地方. 1. google官方下载步骤地址: http://source.android.com/sour ...

  6. Java源码阅读PriorityQueue

    1类签名与简介 public class PriorityQueue<E> extends AbstractQueue<E> implements java.io.Serial ...

  7. tomcat进阶操作

      1.使用war包部署web站点 [root@tomcat webapps]# pwd /application/tomcat/webapps [root@tomcat webapps]# rz   ...

  8. 倍福TwinCAT(贝福Beckhoff)常见问题(FAQ)-如何让不同的PLC程序分线程运行 TC3

    右击Tasks,添加一个新的Task   可以为这个线程设置自定义的扫描周期   然后在项目上右击添加Referenced Task   在TaskSub1上右击添加现有项,把之气写好的PRG程序绑定 ...

  9. lodash _.size

    返回collection(集合)的长度,如果集合是类数组或字符串,返回其 length :如果集合是对象,返回其可枚举属性的个数. _.size([1, 2, 3]); // => 3 _.si ...

  10. Gperftools中tcmalloc的简介和使用(转)

    TcMalloc(Thread-CachingMalloc)是google-perftools工具中的一个内存管理库,与标准的glibc库中malloc相比,TcMalloc在内存分配的效率和速度上要 ...