Coprime numbers

2.5

4 votes
Number Theory, Implementation, Number theory, Integer Factorization, Bitmask, Algorithms, Bit manipulation, Sieve, Math
Problem

You are given the number N.

Determine the number of pairs P,Q such that they satisfies the following conditions:

  • 1<P<Q,P×QN
  • Numbers P and Q are co-prime numbers

Note: Two integers a and b are called coprime, relatively prime, or mutually prime, if the only positive integer that is a divisor of both of these numbers is 1.

Input format

  • The first contains an integer T that denotes the number of test cases in the input.
  • The next T lines contain an integer N.

Output format

Print T lines. The ith line must contain the answer for the ith test case.

Constraints

1T10

1N109

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In the first case the following pairs are suitable for us: (2,3);(2,5);(3,4).

In the second case the following pairs are suitable for us: (2,3);(2,5);(2,7);(2,9);(3,4);(3,5).

Editor Image

?