题解:素数筛+唯一分解定理

可以把素数筛那部分放到while之外,减小时间复杂度。

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <assert.h> const int maxn = 110000005;
const int mod = 100000007;
const int N = 60000008;
int prime[N];
bool vis[maxn];
int main()
{
int n;
while(~scanf("%d",&n)){
assert(1 <= n && n <= 100000000);
long long ans = 1;
int cnt=0;
memset(vis,false, sizeof(vis));
for (int i = 2; i <= n; i++)
{
if (!vis[i])
{
prime[cnt++] = i;
for (long long j = i; j <= n; j *= i)
{
ans = ans * i % mod;
}
}
for (int j = 0; j < cnt; j++)
{
long long x = i * prime[j];
if (x > n)break;
vis[x] = true;
if (i%prime[j] == 0)break;
}
}
printf("%lld\n",ans);
}
return 0;
}

最新文章

  1. OC-《购票系统》
  2. 在windows上搭建react-native的android环境
  3. web api 开发记录
  4. json_encode中文unicode的问题
  5. 也不知怎么了LVS.SH找不到,网上搜了一篇环境搭配CENTOS下面的高可用 参考
  6. FreeSWITCH一些需求应对
  7. 2659: [Beijing wc2012]算不出的算式 - BZOJ
  8. NSString+URLEncoding.h --使用Obj-C对数据等进行URLEncoding编码
  9. Oracle 监听器无法启动(TNS-12555,TNS-12560,TNS-00525)
  10. duilib之源码分析
  11. Windows 驱动发展基金会(九)内核函数
  12. 克隆虚拟机win8系统后注意修改安全标识(SID)
  13. 【iOS】swift 74个Swift标准库函数
  14. IrisSkin 单独控件样式设置 不使用皮肤样式
  15. Delphi 2010 新增功能之: IOUtils 单元(6): TPath(结构体) 的方法与属性
  16. 在vue2.0中引用element-ui组件库
  17. poj1664放苹果(递归)
  18. 5月16 JSON的一些知识点及AJAX的应用
  19. inception+archery SQL审核平台
  20. 使用express框架和mongoose在MongoDB删除数据

热门文章

  1. 【转载】网站配置Https证书系列(二):IIS服务器给网站配置Https证书
  2. 微信开发者工具 关于no such file or directory
  3. ios9 字符串与UTF-8 互相转换
  4. Redis系列之-—内存淘汰策略(笔记)
  5. CentOS7安装CDH 第八章:CDH中对服务和机器的添加与删除操作
  6. layui 添加
  7. Django中使用JWT
  8. Linux的desktop文件正常编写赋权,仍无法打开解决办法
  9. {RuntimeError} An attempt has been made to start a new process before the current process has finished its bootstrapping phase.This probably means that you are not using fork to start your child...
  10. MySQL面试问题