[Cpp]
/*
* Rule: After a table is created, it is found that in the range of n, only 2 ^ x, and 2 times of the number of rows and number of rows meet the requirements.
* That Is, 2 ^ 1, 2 ^ 2 ,... 1*1, 2*2 ,... 2*1*1, 2*2*2, 2*3*3... and so on. You just need to repeat it.
* Url: http://uva.onlinejudge.org/index.php? Option = onlinejudge & page = show_problem & problem = 2390
* Stratege: law, logarithm
* Author: Johnsondu
*/
# Include <iostream> www.2cto.com
# Include <cmath>
# Include <cstdio>
# Include <cstring>
Using namespace std;
# Define LL long
LL n, t1, t2, t3, t4, t5, t6;
Int main ()
{
Int tcase, cas = 1;
Scanf ("% d", & tcase );
While (tcase --)
{
Scanf ("% lld", & n );
If (n = 1)
{
Printf ("Case % d: 0 \ n", cas ++ );
Continue;
}
T1 = (LL) sqrt (n * 1.0); // a total of t1 ^ 2 <n, so there are t1
T2 = (LL) (log (n * 1.0)/log (2.0); // 2 ^ t2 contains t2
T3 = (LL) (log (n * 1.0)/log (2.0)-1)/2 + 1; // 2 * x and 2 ^ t2, and 2 ^ 3, 2 ^ 7 ,..., repeated
T4 = (LL) sqrt (n/2.0); // 2 * x A total of t4
T5 = (LL) (log (t1 * 1.0)/log (2.0); // in t1, x * x and 2 ^ t2 duplicate t5
Printf ("Case % d: % lld \ n", cas ++, n-(t1-t5 + t2 + t4-t3 ));
}
Return 0;
}
/*
Code for table creation:
# Include <iostream>
# Include <cmath>
# Include <cstdio>
# Include <cstring>
Using namespace std;
# Define LL long
# Define maxn33000
Int p [MAXN];
Bool isPrime [MAXN];
Int prilen, a, B;
Void getPrime ()
{
Int I;
For (I = 0; I <MAXN; I ++)
{
IsPrime [I] = true;
}
For (I = 4; I <MAXN; I + = 2)
IsPrime [I] = false;
P [0] = 2;
Prilen = 1;
For (I = 3; I <MAXN; I + = 2)
{
If (isPrime [I])
{
Int tmp = 2 * I;
P [prilen ++] = I;
While (tmp <MAXN)
{
IsPrime [tmp] = false;
Tmp + = I;
}
}
}
}
Int get (int n)
{
Int ans = 1;
Int t = n;
For (int I = 0; p [I] * p [I] <= t; I ++)
{
If (t % p [I] = 0)
{
Int num = 0;
While (t % p [I] = 0)
{
Num ++;
T/= p [I];
}
Ans = ans * (int) pow (p [I] * 1.0, num + 1.0)-1)/(p [I]-1 );
}
}
If (t> 1)
Ans = ans * (int) pow (t * 1.0, 2.0)-1)/(t-1 );
Return ans;
}
Int main ()
{
GetPrime ();
// Int ans = 0;
For (int I = 1; I <= 1000; I ++)
{
// Printf ("% d -- % d \ n", I, get (I ));
If (get (I) % 2! = 0)
Printf ("% d --- % d \ n", I, get (I ));
}
Return 0;
}
1 --- 1
2 --- 3
4 --- 7
8 --- 15
9 --- 13
16 --- 31
18 --- 39
25 --- 31
32 --- 63
36 --- 91
49 --- 57
50 --- 93
64 --- 127
72 --- 195
81 --- 121
98 --- 171
100 --- 217
121 --- 133
128 --- 255
144 --- 403
162 --- 363
169 --- 183
196 --- 399
200 --- 465
225 --- 403
242 --- 399
256 --- 511
288 --- 819
289 --- 307
324 --- 847
338 --- 549
361 --- 381
392 --- 855
400 --- 961
441 --- 741
450 --- 1209
484 --- 931
512 --- 1023
529 --- 553
576 --- 1651
578 --- 921
625 --- 781
648 --- 1815
676 --- 1281
722 --- 1143
729 --- 1093
784 --- 1767
800 --- 1953
841 --- 871
882 --- 2223
900 --- 2821
961 --- 993
968 --- 1995
*/