Description
Input
只有一行一个整数 N(0 < N < 1000000)。
Output
只有一行输出,为整数M,即f(1)到f(N)的累加和。
Sample Input
3
Sample Output
5
题解
水题一道...做不出的要$AFO$了...
1 //It is made by Awson on 2017.11.10 2 #include <map> 3 #include <set> 4 #include <cmath> 5 #include <ctime> 6 #include <queue> 7 #include <stack> 8 #include <cstdio> 9 #include <string> 10 #include <vector> 11 #include <cstdlib> 12 #include <cstring> 13 #include <iostream> 14 #include <algorithm> 15 #define LL long long 16 #define LD long double 17 #define Max(a, b) ((a) > (b) ? (a) : (b)) 18 #define Min(a, b) ((a) < (b) ? (a) : (b)) 19 #define sqr(x) ((x)*(x)) 20 #define y1 yy 21 #define count COUNT 22 #define Lr(o) (o<<1) 23 #define Rr(o) (o<<1|1) 24 using namespace std; 25 const int N = 1000000; 26 27 int n; 28 LL ans; 29 30 void work() { 31 scanf("%d", &n); 32 for (int i = 1; i <= n; i++) 33 ans += n/i; 34 printf("%lld ", ans); 35 } 36 int main() { 37 work(); 38 return 0; 39 }