[NOI2010]:能量采集
来源:互联网 发布:修改apache配置文件 编辑:程序博客网 时间:2024/06/11 19:47
传送门
首先,80分暴力很明显,直接枚举然后算gcd就好了
然后其实100分也很简单(要不然怎么可能给80分暴力)
枚举gcd,然后算有多少个gcd(i,j)=d就好了,这里需要减去之前重复的,可以看我的代码。
代码:
#include<cstdio>#include<cstdlib>#include<cmath>#include<cstring>#include<algorithm>#define ll long longusing namespace std;const int N=1e5+5;int n,m;ll f[N],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;}
阅读全文
0 0
- NOI2010 能量采集
- BZOJ[Noi2010]能量采集
- 【NOI2010】能量采集
- 2005: [Noi2010]能量采集
- 【NOI2010】【BZOJ2005】能量采集
- [BZOJ2005][Noi2010]能量采集
- [BZOJ2005][Noi2010]能量采集
- bzoj2005【NOI2010】能量采集
- 能量采集[NOI2010][Codevs1937]
- NOI2010 能量采集
- Bzoj2005[Noi2010]能量采集
- [bzoj2005][Noi2010]能量采集
- 2005: [Noi2010]能量采集
- 【NOI2010】bzoj2005 能量采集
- BZOJ2005 [Noi2010]能量采集
- bzoj2005[Noi2010]能量采集
- 【bzoj2005】[Noi2010]能量采集
- bzoj2005 [Noi2010]能量采集
- 图像的逻辑变换
- 大数据处理中基于概率的数据结构
- 镜像
- leetcode 54. Spiral Matrix
- 指向结构体的指针数组,应用
- [NOI2010]:能量采集
- java -- 接口
- windows&mongodb
- 16讲 序列!序列!
- 幂方的最后一位
- C++中的默认函数与default和delete用法
- 数据结构实验之链表七:单链表中重复元素的删除
- 初级程序员只会Ctrl + C + V
- 关于const