代码

#include <bits/stdc++.h>
#define rin(i,a,b) for(int i=(a);i<=(b);++i)
#define irin(i,a,b) for(int i=(a);i>=(a);--i)
#define trav(i,a) for(int i=head[(a)];i;i=e[i].nxt)
typedef long long LL;
using std::cin;
using std::cout;
using std::endl; inline LL read(){
LL x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
return x*f;
} const LL MAXN=10000000005;
const LL MOD=2999999;
LL n,prm[200005],cnt;
LL num[200005],g[200005],tot;
bool vis[200005];
struct Hash_Table{
int head[MOD+5],nxt[200005],siz;
LL to[200005],val[200005];
inline void insert(LL x,LL y){
++siz;
nxt[siz]=head[x%MOD];
to[siz]=y;
val[siz]=x;
head[x%MOD]=siz;
}
inline LL operator [] (LL x){
for(register int i=head[x%MOD];i;i=nxt[i])
if(val[i]==x) return to[i];
}
}mp; void pre_process(LL n){
rin(i,2,n){
if(!vis[i]) prm[++cnt]=i;
for(register int j=1;j<=cnt&&i*prm[j]<=n;++j){
vis[i*prm[j]]=1;
if(i%prm[j]==0) break;
}
}
} int main(){
n=read();
pre_process((LL)(sqrt(n)+0.5));
LL nxti;
for(register LL i=1;i<=n;i=nxti){
nxti=n/(n/i)+1;
num[++tot]=n/i;
mp.insert(num[tot],tot);
g[tot]=num[tot]-1;
}
rin(i,1,cnt){
rin(j,1,tot){
if(prm[i]*prm[i]>num[j]) break;
int k=mp[num[j]/prm[i]];
g[j]-=g[k]-(i-1);
}
}
printf("%lld",g[1]);
return 0;
}

最新文章

  1. C#如何反射出委托的签名,如何使用反射调用委托
  2. .NET魔法堂:工程构建基石-&gt;MSBuild
  3. NYOJ题目768移位密码
  4. Leetcode Sqrt(x)
  5. javascript图片库
  6. .cmd文件不小心管理记事本打开的恢复
  7. ajax读取txt文件
  8. Pluto - iOS 上一个高性能的排版渲染引擎
  9. oracle解决导入高版本dmp报错问题:IMP-00058: ORACLE error 12547 encountered
  10. caffe生成deploy.prototxt文件
  11. JAVA 和.NET在安全功能的比较
  12. dll反编译工具总结
  13. redis清除缓存和连接远程服务器
  14. 编程调节Win7/Win8系统音量的一种方法
  15. Qt编写自定义控件12-进度仪表盘
  16. 公司里面用的iTextSharp(教程)---简介
  17. 组件化表单解决方案AForm 1.3 发布
  18. solr5.5.0在CenOS上的安装与配置
  19. Druid.io系列(八):部署
  20. 【SPOJ -NSUBSTR】Substrings 【后缀自动机+dp】

热门文章

  1. Oracle 单实例安装篇
  2. Java基础——Modifier类
  3. 剑指offer 数字翻译成字符串
  4. Scala学习笔记(3)
  5. 使用vue-cli构建vue项目流程
  6. Vue 小实例 - 组件化 、cli 工程化
  7. Apache ab测试工具使用方法(无参、get传参、post传参)(转)
  8. 在Linux中让echo命令显示带颜色的字
  9. Django中数据库的增删改查
  10. python2 &#39;ascii&#39;编码问题