[NOI2010]:能量采集
2017-12-13 21:46
295 查看
传送门
首先,80分暴力很明显,直接枚举然后算gcd就好了
然后其实100分也很简单(要不然怎么可能给80分暴力)
枚举gcd,然后算有多少个gcd(i,j)=d就好了,这里需要减去之前重复的,可以看我的代码。
代码:
首先,80分暴力很明显,直接枚举然后算gcd就好了
然后其实100分也很简单(要不然怎么可能给80分暴力)
枚举gcd,然后算有多少个gcd(i,j)=d就好了,这里需要减去之前重复的,可以看我的代码。
代码:
#include<cstdio> #include<cstdlib> #include<cmath> #include<cstring> #include<algorithm> #define ll long long using namespace std; const int N=1e5+5; int n,m; ll f ,ans; int main(){ scanf("%d %d",&n,&m); if(n>m)swap(n,m); for(int i=n;i>=1;i--){ f[i]=(ll)(n/i)*(ll)(m/i); for(int j=(i<<1);j<=n;j+=i)f[i]-=f[j]; ans+=(ll)((i<<1)-1)*f[i]; } printf("%lld",ans); return 0; }
相关文章推荐
- BZOJ 2005 NOI2010 能量采集 莫比乌斯反演
- [NOI2010] 能量采集
- 【bzoj2005】[Noi2010]能量采集 莫比乌斯反演
- BZOJ2005 [Noi2010]能量采集 递推+容斥/欧拉函数
- BZOJ 2005: [Noi2010]能量采集 [莫比乌斯反演]
- 【bzoj2005】 [Noi2010]能量采集 数学结论(gcd)
- 【NOI 2010】【BZOJ 2005】【JZOJ 2225】能量采集
- [NOI2010 能量采集]
- 洛谷P1447 - [NOI2010]能量采集
- Problem Seven:[NOI 2010 能量采集]
- Noi 2010 day1 第一题 能量采集
- 【BZOJ 2005】[Noi2010]能量采集
- BZOJ 2005 [Noi2010]能量采集 ——Dirichlet积
- bzoj2005 [Noi2010]能量采集
- NOI 2010 能量采集
- 【BZOJ】【2005】【NOI2010】能量采集
- [Noi 2010][BZOJ 2005][JZOJ 2225]能量采集
- 【NOI2010】【BZOJ2005】能量采集
- [NOI 2010]能量采集
- 2005: [Noi2010]能量采集