1. 程式人生 > >1968: [Ahoi2005]COMMON 約數研究

1968: [Ahoi2005]COMMON 約數研究

led gre pos ems () bmi eve memory style

1968: [Ahoi2005]COMMON 約數研究

Time Limit: 1 Sec Memory Limit: 64 MB
Submit: 3354 Solved: 2289
[Submit][Status][Discuss]

Description

技術分享圖片

Input

只有一行一個整數 N(0 < N < 1000000)。

Output

只有一行輸出,為整數M,即f(1)到f(N)的累加和。

Sample Input

3

Sample Output

5

code

換個角度去思考

技術分享圖片
 1 #include<cstdio>
 2
3 int main () { 4 int n; 5 scanf("%d",&n); 6 long long ans = 0; 7 for (int i=1; i<=n; ++i) { 8 ans += (n / i); 9 } 10 printf("%lld",ans); 11 return 0; 12 }
View Code

1968: [Ahoi2005]COMMON 約數研究