F (n) is the and of all the divisors of N, give you a number of n, let you ask from 1 to n in the number of F (n) are even numbers how many
Analysis:
The factor of number x and f (x) = (1+P1+P1^2+P1^3+...+P1^A1) * (1+P2+P2^2+...+P2^A2) *...* (1+pn+pn^2+...+pn^an);
Because even or even, odd-numbered or odd-numbered, odd-numbered even is even, all must have an odd number in each bracket, and then minus the divisors and odd numbers is the answer.
1. When x is 2, 2 of the corresponding brackets and must be an odd number, because even plus 1 must be odd.
2. Except for 2, all primes are odd, and to make x the corresponding number of other elements of the parentheses and the odd, you must ensure that X has even several of the factor, that AI must be even.
3. The number that satisfies the above two conditions is a square number, that is, the divisor and the odd number x, it must be a square number, and of course the number x multiplied by 2 is also satisfying the 2*x and odd numbers.
So just subtracting the n minus sqrt (n) and sqrt (N/2) is the answer. You can also find the number of squares within n, and the number of 2* squared number not more than n, and the answer is after the n minus.
The first method:
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long LL;
int main ()
{
int T;
scanf ("%d", &t);
for (int kase = 1; kase <= T; kase++)
{
ll n, sum;
scanf ("%lld", &n);
sum = n;
Sum-= (int) sqrt (n);
Sum-= (int) sqrt (N/2);
printf ("Case%d:%lld\n", Kase, sum);
}
return 0;
}
The second method:
#include <stdio.h>
int main ()
{
int T, Kase = 0;
Long long N;
scanf ("%d", &t);
while (t--)
{
scanf ("%lld", &n);
Long ans = 0;
for (Long i = 1; i*i <= N; i++)
{
ans++;
if (2*i*i<=n)
ans++;
}
printf ("Case%d:%lld\n", ++kase, N-ans);
}
return 0;
}