前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CodeForces 664A Complicated GCD

CodeForces 664A Complicated GCD

作者头像
ShenduCC
发布2018-04-26 17:07:17
7030
发布2018-04-26 17:07:17
举报
文章被收录于专栏:算法修养

A. Complicated GCD

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 bare 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.

Examples

input

代码语言:javascript
复制
1 2

output

代码语言:javascript
复制
1

input

代码语言:javascript
复制
61803398874989484820458683436563811772030917980576 61803398874989484820458683436563811772030917980576

output

代码语言:javascript
复制
61803398874989484820458683436563811772030917980576
代码语言:javascript
复制
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
char a[200];
char b[200];
int main()
{
    scanf("%s%s",a,b);
    int len1=strlen(a);
    int len2=strlen(b);
    if(len1<len2) {printf("1\n");return 0;}
    else{
        for(int i=0;i<len1;i++){
            if(a[i]!=b[i]){
                printf("1\n");return 0;
            }
        }
        for(int i=0;i<len1;i++)
        printf("%c",a[i]);
        cout<<endl;
        return 0;
    }

}

Codeforces (c) Copyright 2010-2016 Mike

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2016-04-29 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档