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
|
||||||||||||||
2019-09-28 21:42:38
My 50th on SPOJ!! |
||||||||||||||
2019-07-13 06:42:47
if u r using cin and cout then copy this lines ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); |
||||||||||||||
2019-06-19 06:10:26
find gcd, and dont use printf |
||||||||||||||
2019-05-30 20:07:31
Nice problem :) |
||||||||||||||
2019-04-13 15:42:27
Only a single cin and cout will cost you TLE don't need to seive just find gcd and then count divisor happy coding |
||||||||||||||
2019-04-09 17:54:13 Muhammad Annaqeeb
Here is a note about comparing the same solution speed across different programming languages: C++ with non-optimized cin and cout ---Time Limit Exceeded C++ with optimized cin and cout -- 0.32 second Java with non-optimized IO -- Time Limit Exceeded Java with optimized IO -- 0.52 second Free Pascal with non-optimized IO -- 0.34 second |
||||||||||||||
2019-03-18 19:48:13
using scanf and printf instead of cin and cout could help! |
||||||||||||||
2019-03-18 17:47:12
WTH How can using cout instead of printf cost a WA Last edit: 2019-03-18 17:47:35 |
||||||||||||||
2019-03-15 12:01:22
I don't what to do anymore --- should I use cin, cout or scanf ,printf |
||||||||||||||
2019-02-12 10:59:06
this was wayy more easy than i thought, O(sqrt(gcd(a,b))) |