bzoj 2005 能量采集 莫比乌斯反演
来源:互联网 发布:hse风险矩阵标准 编辑:程序博客网 时间:2024/06/06 00:39
我们要求的是
化简得
所以我们现在只需要求出
=
=
预处理
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<ctime>#define N 100500using namespace std;int prime[N],tot,n,m;long long phi[N],ans;bool bo[N];void init(){ phi[1]=1; for(int i=2;i<=n;i++){ if(!bo[i]){ prime[++tot]=i; phi[i]=i-1; } for(int j=1;j<=tot&&i*prime[j]<=n;j++){ bo[i*prime[j]]=1; if(i%prime[j]==0){ phi[i*prime[j]]=phi[i]*prime[j]; break; } else phi[i*prime[j]]=phi[i]*(prime[j]-1); } } for(int i=1;i<=n;i++)phi[i]+=phi[i-1];}int main(){ scanf("%d%d",&n,&m); if(n>m)swap(n,m); init(); for(int i=1,j;i<=n;i=j+1){ j=min(n/(n/i),m/(m/i)); ans+=(long long)(phi[j]-phi[i-1])*(n/i)*(m/i); } ans*=2; ans-=(long long)n*m; printf("%lld\n",ans); return 0;}
阅读全文
0 0
- BZOJ 2005 能量采集(莫比乌斯反演)
- Bzoj 2005: [Noi2010]能量采集(莫比乌斯反演)
- BZOJ 2005 NOI2010 能量采集 莫比乌斯反演
- BZOJ 2005: [Noi2010]能量采集(莫比乌斯反演)
- bzoj 2005 能量采集 莫比乌斯反演
- bzoj 2005 能量采集(莫比乌斯反演)
- BZOJ 2005-能量采集(莫比乌斯反演)
- BZOJ 2005 能量采集(莫比乌斯反演+分块)
- bzoj 2005 [Noi2010]能量采集 O(n)莫比乌斯反演
- bzoj2005: [Noi2010]能量采集 莫比乌斯反演
- 【bzoj2005】[Noi2010]能量采集 莫比乌斯反演
- [BZOJ2005][NOI2010]能量采集(莫比乌斯反演)
- [bzoj2005][莫比乌斯反演][Noi2010]能量采集
- [BZOJ2005][NOI2010]能量采集(莫比乌斯反演)
- BZOJ 2005 能量采集 (Mobius反演)
- 【BZOJ2005】【NOI2010】能量采集(莫比乌斯反演,容斥原理)
- BZOJ 2005 莫比乌斯反演
- bzoj 2301 莫比乌斯反演
- 第四节总结
- C++继承重名问题
- MAC版E信心跳包加密KEY的逆向
- 最长上升子序列问题(LIS)和最长公共子序列问题(LCS)
- STM32F4_RCC系统时钟配置及描述
- bzoj 2005 能量采集 莫比乌斯反演
- Google大数据三宝之MapReduce
- 读写锁:ReadWriteLock
- C51 定时器Timer使用,及产生1ms系统Tick
- 最短路——解决负权边(Bellman算法)
- MySQL日志种类分析
- Java IO的RandomAccessFile的使用
- 系统编程函数之进程及进程通信
- 组合数公式&Lucas大组合数