BZOJ 1968: [Ahoi2005]COMMON 约数研究

 

水题....随便写都可以过

---------------------------------------------------------------------------

#include<cstdio>
#include<cstring>
#define clr(x, c) memset(x, c, sizeof(x))
using namespace std;
const int maxn = 1000000 + 5;
int f[maxn];
int main()
{
// freopen("test.in", "r", stdin);
clr(f, 0);
int n;
scanf("%d", &n);
for(int i = 1; i <= n; ++i)
for(int j = i; j <= n; j += i) f[j]++;
int ans = 0;
for(int i = 1; i<= n; ++i) ans += f[i];
printf("%d\n", ans);
return 0;
}

--------------------------------------------------------------------------- 

1968: [Ahoi2005]COMMON 约数研究

Time Limit: 1 Sec  Memory Limit: 64 MB
Submit: 1119  Solved: 848
[Submit][Status][Discuss]

Description

Input

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

Output

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

Sample Input

3

Sample Output

5

HINT

Source

 

posted @ 2015-04-26 09:15  JSZX11556  阅读(192)  评论(0编辑  收藏  举报