All submissions to this problem are available.
Given an integer N. Integers A and B are chosen randomly in the range [1..N]. Calculate the probability that greatest Common Divisor (GCD) of A and b equals to b.
Input
The ' The ' input contains an integer T denoting the number of test cases. The description of T test cases follows. Each test case consists of the a single integer N on a separate line.
Output
For each test case, the output a single line containing probability as a irreducible fraction.
Given an integer N. Integers A and B are chosen randomly in the range [1..N]. Calculate the probability that greatest Common Divisor (GCD) of A and b equals to b.
Input
The ' The ' input contains an integer T denoting the number of test cases. The description of T test cases follows. Each test case consists of the a single integer N on a separate line.
Output
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/
For each test case, the output a single line containing probability as a irreducible fraction.
Example
Input:
3
1
2
3
Output:
1/1
3/4
5/9
Constraints
1<=T<=103
1<=N<=109
This is also a maths problem.
There are two knowledge points:
1 Algorithm for finding GCD
2 The logarithm that is equal to the two number of a numeric value-this is a mathematical formula
It is said that here is a detailed analysis of mathematics, interested in research:
Http://matwbn.icm.edu.pl/ksiazki/mon/mon42/mon4204.pdf
OJ System:
http://www.codechef.com/problems/COOLGUYS/
Long Long mgcd (long long A, long B) {long long c = 0;
while (b) {c = b;
b = a% B;
A = C;
return C;
Long Long Pairsofcoolguys (long long N) {long long ans = 0;
Long Long sq = (long long) sqrt (n);
for (Unsigned i = 1; I <= sq; i++) {ans = n/i;
Ans = (ans<<1)-sq*sq;
return ans;
} void Coolguys () {long long n = 0;
int T = 0;
cin>>t;
while (t--) {cin>>n;
Long PS = Pairsofcoolguys (n);
n *= N;
Long Long D = MGCD (PS, N);
cout << (ps/d) << "/" << (n/d) << "\ n"; }
}