题目链接:http://codeforces.com/contest/664/problem/A

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
1 2
output
1
input
61803398874989484820458683436563811772030917980576 61803398874989484820458683436563811772030917980576
output
61803398874989484820458683436563811772030917980576

解题报告:

可以看到,两个字符串相同,输出这个字符串,否则输出1;

#include <stdio.h>
#include <iostream>
#include <string> using namespace std; int main()
{
string a,b;
cin>>a>>b;
if(a==b) cout<<a<<endl;
else cout<<""<<endl;
return ;
}

Codeforces Round #347 (Div.2)_A. Complicated GCD的更多相关文章

  1. Codeforces Round #347 (Div. 2)

    unrating的一场CF A - Complicated GCD #include <bits/stdc++.h> const int N = 1e5 + 5; char a[105], ...

  2. Codeforces Round #554 (Div. 2)-C(gcd应用)

    题目链接:https://codeforces.com/contest/1152/problem/C 题意:给定a,b(<1e9).求使得lcm(a+k,b+k)最小的k,若有多个k,求最小的k ...

  3. Codeforces Round #347 (Div. 2) A

    Description Greatest common divisor GCD(a, b) of two positive integers a and b is equal to the bigge ...

  4. Codeforces Round #511 (Div. 2)-C - Enlarge GCD (素数筛)

    传送门:http://codeforces.com/contest/1047/problem/C 题意: 给定n个数,问最少要去掉几个数,使得剩下的数gcd 大于原来n个数的gcd值. 思路: 自己一 ...

  5. Codeforces Round #651 (Div. 2) A. Maximum GCD(数论)

    题目链接:https://codeforces.com/contest/1370/problem/A 题意 有 $n$ 个数大小分别为 $1$ 到 $n$,找出两个数间最大的 $gcd$ . 题解 若 ...

  6. Codeforces Round #347 (Div. 2) C. International Olympiad 找规律

    题目链接: http://codeforces.com/contest/664/problem/C 题解: 这题最关键的规律在于一位的有1989-1998(9-8),两位的有1999-2098(99- ...

  7. Codeforces Round #347 (Div. 2) B. Rebus

    题目链接: http://codeforces.com/contest/664/problem/B 题意: 给你一个等式,把等式左边的问号用1到n(n为等式右边的数)的数填好,使得等式成立 题解: 贪 ...

  8. Codeforces Round #518 (Div. 2) B. LCM gcd+唯一分解定律

    题意:给出b 求lcm(a,b)/a 在b从1-1e18有多少个不同得结果 思路lcm*gcd=a*b  转换成    b/gcd(a,b) 也就是看gcd(a,b)有多少个值  可以把b 由唯一分解 ...

  9. Codeforces Round #207 (Div. 1) B (gcd的巧妙运用)

    比赛的时候不知道怎么写... 太弱了. 看了别人的代码,觉得这个是个经典的知识点吧. gcd的巧妙运用 自己想的时候苦苦思考怎么用dp求解. 无奈字符串太长而想不出好的算法. 其实在把a和b字符串都分 ...

随机推荐

  1. python3 杂记

    python3 杂记 test001 --test001.py       ( from test2.test002 import * def test1(): print('1') if __nam ...

  2. 3.数据校验和SpringEL

    1.数据验证 数据验证不应该被限定在web层去处理,他应该在任何需要做数据验证的地方做验证: 基于以上考虑,Spring设计了一个既方便又可以在所有层使用的Validator接口 Spring提供了V ...

  3. spring 通过beanDefinition注册自定义规则的bean

    目的: 扫描某个自定义注解标注的类, 或者自定义xml 为这些类生成spring Bean 基本原理:org.springframework.beans.factory.support.Default ...

  4. 复制虚拟机出现”适配器 的mac地址在保留地址范围内‘’

    首先我的虚拟机是复制出来的,选择我已经移到,但是结果会出现了以下情况,导致了我无法ping 通,先看下提示: 使用:ipconfig –all 命令查寻,果然再现有打开的虚拟机中,存在两个mac地址相 ...

  5. ubuntu 重新启动 导致 Namenode无法启动

    hadoop 单节点安装成功了之后,心情那是叫一个激动.不过后来不知道为什么系统相当的慢.于是就把系统重启了.但是不妙的是namenode各种无法启动. 原来的配置: core-site.xml &l ...

  6. shell中获取本机ip地址

    shell中获取本机ip地址 方法一: /sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr ...

  7. [转]Using the HTML5 and jQuery UI Datepicker Popup Calendar with ASP.NET MVC - Part 4

    本文转自:http://www.asp.net/mvc/overview/older-versions/using-the-html5-and-jquery-ui-datepicker-popup-c ...

  8. (转)rsync数据备份方案

    rsync数据备份方案 原文:http://blog.51cto.com/irow10/1826458 最近整理了下公司的数据备份情况.以下是部分操作的过程 1.rsync数据备份,具体备份过程就不详 ...

  9. SmartRF Flash Programmer突然打不开显示界面的办法【亲测有效】

    在尝试打开任务管理器结束任务之后重新打开依然无果,在尝试了SmartRF Flash Programmer卸载重装无数次之后依然无果的况状,我被SmartRF Flash Programmer存在界面 ...

  10. DEDE模板中如何运行php脚本和php变量的使用

    在使用dede模板的时候,经常会需要直接对dede数据库的底层字段进行处理,如果dede中没有相应的函数的时候,往往就需要我们想办法来处理了. 举例:我想取出数据表addonimages中的某一条记录 ...