UVa11526 H(n)

http://blog.csdn.net/synapse7/article/details/12873437

 

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<cstdlib>
 4 #include<algorithm>
 5 #include<iostream>
 6 
 7 using namespace std;
 8 
 9 typedef long long LL;
10 
11 #include<cmath>
12 LL H(int n) {
13     LL res = 0;
14     int m = floor(sqrt(n + 0.1));
15     for(int i = 1; i <= m; i++) {
16         res += n / i;
17     }
18     return (res << 1) - m * m;
19 }
20 
21 int main() {
22     int T, n; scanf("%d", &T);
23     while(T--) {
24         scanf("%d", &n);
25         printf("%lld\n", H(n));
26     }
27     
28     return 0;
29 }

 

你可能感兴趣的:(UVa11526 H(n))