Submit | All submissions | Best solutions | Back to list |
VGCD - The Very Greatest Common Divisor |
Given two integers a and b find their greatest common divisor.
Input
The first line of the input file contains number 0 < n < 1000 the amount of tests. The description of n test cases follow. The description of a test case consists of two lines. The first line contains integer a (0 < a < 10^12540), the second – integer b (0 < b < 10^12540). It is also known that all the numbers in the input file are the determinants of the square matrix of the form:
Output
For each test case print the greatest common divisor of integers a and b on a separate line.
Example
Input: 3 2 3 3 21 6765 610 Output: 1 3 5
Added by: | Spooky |
Date: | 2010-04-09 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: NODEJS OBJC PERL6 SQLITE VB.NET |
Resource: | Open All-Ukrainian Collegiate Contest Semi-Final, 2010 |
hide comments
|
|||||
2010-07-24 17:53:40 Pavel Kuznetsov
Be careful, because there are some non digit symbols after numbers, probably spaces. |
|||||
2010-04-11 12:31:41 Spooky
3 and 5 are determinants of the matrix of the given above form when its dimensions are 3x3 and 4x4 respectively... |
|||||
2010-04-11 12:31:41 Robert Gerbicz
The three tests means: gcd(2,3)=1 gcd(3,21)=3 gcd(6765,610)=5 |
|||||
2010-04-11 12:31:41 ~!(*(@*!@^&
The first line is A, the second line is B, not the dimension of the matrix. Thanks Robert Gerbicz. Last edit: 2010-04-10 00:22:06 |
|||||
2010-04-11 12:31:41 Alexey Shchepin
Beware of DOS-newlines (\r\n) in the input. |
|||||
2010-04-11 12:31:41 .:: Pratik ::.
Why do i get so many runtime errors? I've checked my code again and again! |