XTU 1242 Yada number allowance

Source: Internet
Author: User

Yada Numberproblem Description:

Every positive integer can is expressed by multiplication of prime integers. Duoxida says an integer was a yada number if the total amount of 2,3,5,7,11,13 in it prime factors is even.

For instance, 18=2 * 3 * 3 are not a yada number since the sum of amount of 2, 3 are 3, an odd number; While-2 * 5 * is a yada number since the sum of amount of 2, 5 is 2, a even number that satifies the definition O f yada number.

Now, Duoxida wonders how many yada number is among all integers in [1,n].

Input

The first line contains an integer T (no more than) which indicating the number of test cases. In the following T lines containing a integer n. ()

Output

For each case, output the answer on one single line.

Sample Input

2
18
21st

Sample Output

9
11
??????????

Test instructions

Give you a n, ask you 1 to n how many of the number of satisfied factor is the number of 2,3,5,7,11,13 is an even number

Exercises

All x is preprocessed to meet the 2,3,5,7,11,3 of the X, and the number is even. The number of x is slightly greater than 10000

Note that 0 cases are added, that is, 1.

For a number n, the enumeration of all x, for a x,f (n/x) to find out [1,n/x] does not contain the number of 2,3,5,7,11,13 as a factor, this is the classic repulsion problem.

Finally, all F (n/x) sums can be

#include <bits/stdc++.h>using namespacestd;Const intN = 3e6+ -, M = 1e6+Ten, mod = 1e9+7, INF =1e9;typedefLong Longll;Constll MAXN =1e9;intCNT =0, Ans,n;ll b[n];intA[] = {2,3,5,7, One, -};ll gcd (ll a,ll b) {returnb==0? A:GCD (b,a%b);}voidDFS (ll X,intFintnum) {    if(num==6) {        if(!f) b[cnt++] =x; return ; }     while(x<=MAXN) {DFS (X,f,num+1); X*=A[num]; F^=1; }}voidinit () {DFS (1,0,0); Sort (b,b+cnt);}voidINCLU (intIintnum,ll tmp) {    if(tmp>n)return ; if(i>=6) {        if(num==0) ans =0; Else {            if(num&1) ans = ans+n/tmp; ElseAns = ans-n/tmp; }        return ; } inclu (I+1, num,tmp); INCLU (i+1, num+1, tmp*a[i]/gcd (Tmp,a[i]));}voidsolve () {intAns =0; scanf ("%d",&N); intTM =N;  for(intI=0; i<cnt&&b[i]<=tm;i++) {n= tm/B[i]; Ans=0; INCLU (0,0,1); Ans+ = (N-ans); } printf ("%d\n", Ans);}intMain () {intT; CNT=0;    Init (); scanf ("%d",&T);  while(t--) {solve (); }    return 0;}

XTU 1242 Yada number allowance

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.