BZOJ 1968: [Ahoi2005]COMMON 约数研究 水题
2015-08-30 14:26
435 查看
1968: [Ahoi2005]COMMON 约数研究
Time Limit: 20 SecMemory Limit: 256 MB
题目连接
http://www.lydsy.com/JudgeOnline/problem.php?id=1968
Description
Input
只有一行一个整数 N(0 < N < 1000000)。
Output
只有一行输出,为整数M,即f(1)到f(N)的累加和
Sample Input
3
Sample Output
5
HINT
题意
题解:
直接ans+=n/i就好了
表示这个数对整体的贡献值是多少
代码:
//qscqesze #include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <bitset> #include <vector> #include <sstream> #include <queue> #include <typeinfo> #include <fstream> #include <map> #include <stack> typedef long long ll; using namespace std; //freopen("D.in","r",stdin); //freopen("D.out","w",stdout); #define sspeed ios_base::sync_with_stdio(0);cin.tie(0) #define maxn 200051 #define mod 10007 #define eps 1e-9 int Num; //const int inf=0x7fffffff; //нчоч╢С const int inf=0x3f3f3f3f; 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*10+ch-'0';ch=getchar();} return x*f; } //************************************************************************************** int main() { int n=read(); ll ans=0; for(int i=1;i<=n;i++) ans+=n/i; cout<<ans<<endl; }
相关文章推荐
- js判断文件大小
- 初步10-分离各位数
- HDOJ 4463 Outlets 最短路
- Mybatis Association
- 策略模式
- 欢迎使用CSDN-markdown编辑
- MongoDB (四) MongoDB 数据模型
- 算法篇——Cantor的数表
- 关于MVC4-5 添加EF controller时 EF为同级类库时,报错时的问题解决。
- TCP协议的一些问题
- HDOJ 4548 美素数
- JS数组
- disk boot info
- HDU1572-下沙小面的(2)-最短路(深搜)
- 为ESXi配置存储
- MongoDB (三) MongoDB 安装
- mac os x 端口转发(80)
- 物理地址和虚拟地址的区别
- HashSet
- win10怎样还原win7?win10一键还原win7图文教程