bzoj 2820 莫比乌斯反演
来源:互联网 发布:淘宝显示历史价格 编辑:程序博客网 时间:2024/05/22 14:31
搞了一整个晚自习,只是看懂了dalao们的博客,目前感觉没有思路….还是要多切题
next day:
刚才又推了一遍,发现顺过来了,hahaha
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<cmath>using namespace std;const int N=10000000;long long ans,f[N+5];int mm[N+5],prime[N];bool bo[N];int T,n,m,tot;void init(){ mm[1]=1; for(int i=2;i<=N;i++){ if(!bo[i]){prime[++tot]=i;mm[i]=-1;} for(int j=1;j<=tot&&i*prime[j]<=N;j++){ bo[i*prime[j]]=1; if(i%prime[j]!=0)mm[i*prime[j]]=-mm[i]; else{mm[i*prime[j]]=0;break;} } } for(int j=1;j<=tot;j++) for(int i=1;i*prime[j]<=N;i++) f[i*prime[j]]+=mm[i]; for(int i=1;i<=N;i++)f[i]+=f[i-1];}int main(){ init(); scanf("%d",&T); while(T--){ ans=0; scanf("%d%d",&n,&m); if(n>m) swap(n,m); for(int i=1,j;i<=n;i=j+1){ j=min(n/(n/i),m/(m/i)); ans+=(f[j]-f[i-1])*(n/i)*(m/i); } printf("%lld\n",ans); } return 0;}
阅读全文
0 0
- bzoj 2820 莫比乌斯反演
- bzoj 2820 莫比乌斯反演
- BZOJ 2820 莫比乌斯反演
- bzoj 2820 莫比乌斯反演
- bzoj 2301 莫比乌斯反演
- bzoj 2301 莫比乌斯反演
- BZOJ 2818(莫比乌斯反演)
- BZOJ 3309 莫比乌斯反演
- BZOJ 3994 莫比乌斯反演
- BZOJ 2005 莫比乌斯反演
- BZOJ 2301 莫比乌斯反演
- BZOJ 2820 YY的GCD 莫比乌斯反演
- 【莫比乌斯反演】[BZOJ 2820 YY的GCD]
- BZOJ 2820 YY的GCD 莫比乌斯反演
- [莫比乌斯反演] BZOJ 2820 YY的GCD
- BZOJ 2820 YY的GCD(莫比乌斯反演)
- bzoj 2820: YY的GCD 莫比乌斯反演
- BZOJ 2820 YY的GCD 莫比乌斯反演
- 利比亚行动
- Populating Next Right Pointers in Each Node问题及解法
- SSL P2574 Closest
- 【usaco】learning
- could not read data from '/Users/xxxx/xxxx/Info.plist': The file “Info.plist” couldn’t be opened
- bzoj 2820 莫比乌斯反演
- 逻辑卷管理pv,vg,lv
- 开发人员必知的5种开源框架
- mysql外键的优缺点和使用
- C语言存储空间布局以及static解析
- SSL P2575 给出字符串
- java基础第八天 多态
- Console线配置交换机
- 【专题】LCA(最近公共祖先)