首页 > 代码库 > locker doors

locker doors

 1 #include <math.h>
 2 #include <stdio.h>
 3 int f(int n)
 4 {
 5     int i, t, r = 0, q = (int)sqrt(n);//开方了
 6     for (i=1; i<=q; ++i)
 7     {
 8         if (n%i == 0)
 9         {
10             t = n/i;
11             if (t != i)
12             {
13                 r += 2;
14             }
15             else
16             {
17                 ++r;
18             }
19         }
20     }
21     return r;
22 }
23 int main()
24 {
25     int n, i, r;
26     while (scanf("%d", &n) == 1)
27     {
28         r = 0;
29         for (i=1; i<=n; i++)
30         {
31             r += f(i)&1;
32         }
33         printf("%d\n", r);
34     }
35     return 0;
36 }
暂时还看不太明白