题目大意:
求出最小的正整数,它的约数有$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. RabbitMq_05_Topics

    Topics (using the .NET client) Prerequisites This tutorial assumes RabbitMQ isinstalled and running ...

  2. canvas如何兼容IE8

    大家都知道canvas是个非常好玩的东西,但是IE9以下的浏览器不支持,有时候业务需求必须用到canvas,且又要求兼容IE8浏览器,那怎么办呢? 1.添加对html5的支持:<!--[if I ...

  3. Install FileZilla in Ubuntu16.04

    一.安装fileZilla $ sudo add-apt-repository ppa:n-muench/programs-ppa $ sudo apt-get update $ sudo apt-g ...

  4. volatile型变量自增操作的隐患

      用FindBugs跑自己的项目,报出两处An increment to a volatile field isn't atomic.对应报错的代码例如以下: volatile int num = ...

  5. SSH 错误解决案例1:Read from socket failed: Connection reset by peer

    今天早上天天连接的开发机突然报出连接错误. 这个错误是SSH最常见错误,造成的原因也是千奇百怪(具体可goole),下面描述我的server的问题: 客户端报错 [root@server]# ssh ...

  6. linux 压缩、解压缩及归档工具

    linux下主要的压缩.归档工具 compress/uncompress: .Z gzip/gunzip:  .gz bzip2/bunzip2: .bz2 xz/unxz: .xz zip/unzi ...

  7. mysql 5.6 修改root原始密码不为空方法

    mysql 5.6安装好之后,是默认root用户的密码为空的,此时为了安全性需要修改密码不为空,修改方法为: cmd或者mysql 5.6 command line client登陆之后,输入一下命令 ...

  8. Loadrunner11之VuGen常用函数lr_user_data_point(一)

    Loadrunner11之VuGen常用函数lr_user_data_point(一) 上一篇 / 下一篇  2011-11-15 00:15:33 / 精华(1) / 置顶(1) / 个人分类:性能 ...

  9. strults2标签s:set的用法

    struts2标签<s:set></s:set>的用法.原理 http://liuna718-163-com.iteye.com/blog/1124654     我的例子: ...

  10. Jquery全选与反选点击执行一次的解决方案

    在做项目时遇到一个bug,checkbox全选与反选功能,只能点击一次,再点就不起作用了,为了解决此问题,我查找了好多资料,下面把具体解决方案整理分享给大家,需要的朋友可以参考下: 代码需求, 使用a ...