Submit | All submissions | Best solutions | Back to list |
COMDIV - Number of common divisors |
You will be given T (T ≤ 106) pairs of numbers. All you have to tell is the number of common divisors between the two numbers in each pair.
Input
First line of input: T (Number of test cases)
In next T lines, each have one pair A B (0 < A, B ≤ 106)
Output
One integer describing number of common divisors between two numbers.
Example
Input: 3
100000 100000
12 24
747794 238336 Output: 36
6
2
Added by: | Mir Wasi Ahmed |
Date: | 2010-10-31 |
Time limit: | 0.600s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Own problem, used in UODA TST |
hide comments
|
||||||||||||||
2011-06-27 16:46:07 Psycho
@radhakrishnan u r comparing it wit finding prime which can be done in (sqrt(n)) but here, I think its solution requires at least O(min(x,y)) time correct me if i am wrong |
||||||||||||||
2011-06-27 16:46:07 Egor
Solution with 0(n/2 + lnln(n)) is ok on pascal =) without any optimization Last edit: 2011-02-16 16:04:49 |
||||||||||||||
2011-06-27 16:46:07 Prateek Khandelwal
this is for sir Mir Wasi Ahmed,if you will take 10^6 test cases and each test case is "10^6 10^6" then the code i have submitted which is accepted by you will give tle but for your test cases my code is accepted.. Reply: Time limit was set considering the different range of a and b. I don't think whole input should contain the worst case. If you look at the submission statistics you'll see the number of TLEs, so data is not that weak. However, if you think you got lucky then enjoy it. :) Mir Wasi Ahmed Last edit: 2011-02-08 11:00:26 |
||||||||||||||
2011-06-27 16:46:07 Vladimir Kirichenkoff
Yes |
||||||||||||||
2011-06-27 16:46:07 Seshadri R
Should 1 be always counted as one of the common divisors for the given pair? |
||||||||||||||
2011-06-27 16:46:07 [Retired]
TLE |
||||||||||||||
2011-06-27 16:46:07 :D
"will O(sqrt (min(x,y) ) pass?" It's pretty unlikely. |
||||||||||||||
2011-06-27 16:46:07 Radhakrishnan Venkataramani
will O(sqrt (min(x,y) ) pass? |
||||||||||||||
2011-06-27 16:46:07 Mir Wasi Ahmed
@purav: Many solutions including mine used only scanf and got Accepted. So people should not assume that they need fast IO. Sorry to People using some of the slower languages. It seem there is no way I can set different time-limits for different languages. Last edit: 2010-11-03 14:39:15 |
||||||||||||||
2011-06-27 16:46:07 purav
i got TLE with scanf, had to use faster I/O to get acc |