【BZOJ1968】【AHoi2005】COMMON约数研究

Description

Input

只有一行一个整数 N(0 < N < 1000000)。

Output

只有一行输出,为整数M,即f(1)到f(N)的累加和。

Sample Input

3

Sample Output

5

HINT

 

Source

Day2

思路:枚举约数即可。

 1 #include <iostream>
 2 #include <cstdio>
 3 using namespace std;
 4 int main()
 5 {
 6     int n,ans=0;
 7     scanf("%d",&n);
 8     for (int i=1;i<=n;i++)    ans+=n/i;
 9     printf("%d
",ans);
10     return 0;
11 } 
View Code
—Anime Otaku Save The World.
原文地址:https://www.cnblogs.com/DMoon/p/5193633.html