CodeForces 664A Complicated GCD

来源:互联网 发布:tenga iroha 知乎 编辑:程序博客网 时间:2024/05/28 09:32
Complicated GCD
Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u

Submit Status

Description

Greatest common divisor GCD(a, b) of two positive integers a and b is equal to the biggest integer d such that both integers a and b are divisible by d. There are many efficient algorithms to find greatest common divisor GCD(a, b), for example, Euclid algorithm.

Formally, find the biggest integer d, such that all integers a, a + 1, a + 2, ..., b are divisible by d. To make the problem even more complicated we allow a and b to be up to googol, 10100 — such number do not fit even in 64-bit integer type!

Input

The only line of the input contains two integers a and b (1 ≤ a ≤ b ≤ 10100).

Output

Output one integer — greatest common divisor of all integers from a to b inclusive.

Sample Input

Input
1 2
Output
1
Input
61803398874989484820458683436563811772030917980576 61803398874989484820458683436563811772030917980576
Output
61803398874989484820458683436563811772030917980576

Source

Codeforces Round #347 (Div. 2)

Submit Status

Problem descriptions:
System Crawler 2016-04-17 0
Initialization.




如果a==b,答案就是a或者b

如果a!=b,答案只能是1


#include <stdio.h>#include <string.h>const int MAXN=105;char a[MAXN],b[MAXN];int main(){        while(scanf("%s%s",a,b)>0)        {                if(!strcmp(a,b))                        printf("%s\n",a);                else                        printf("1\n");        }        return 0;}



0 0
原创粉丝点击