题目链接:

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

题意:

[a,b]的最大公约数是多少;

思路:

可以发现,a和b不相同时的最大公约数是1,相同时是其本身;

AC代码:
/*2014300227    664A - 9    GNU C++11    Accepted    15 ms    4 KB*/
#include <bits/stdc++.h>
using namespace std;
const int N=1e4+;
typedef long long ll;
const int mod=1e9+;
char str1[],str2[];
int check()
{
int len1=strlen(str1),len2=strlen(str2);
if(len1==len2)
{
for(int i=;i<len1;i++)
{
if(str1[i]!=str2[i])return ;
}
return ;
}
return ;
}
int main()
{
scanf("%s%s",str1,str2);
if(check())printf("%s\n",str1);
else printf("1\n"); return ;
}

codeforces 664A A. Complicated GCD(水题)的更多相关文章

  1. 【Codeforces 664A】 Complicated GCD

    [题目链接] 点击打开链接 [算法] gcd(a,a+1) = 1 所以当a = b时,答案为a,否则为1 [代码] #include<bits/stdc++.h> using names ...

  2. codeforces 577B B. Modulo Sum(水题)

    题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  3. Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树

    A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...

  4. codeforces 696A Lorenzo Von Matterhorn 水题

    这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...

  5. CodeForces 589I Lottery (暴力,水题)

    题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...

  6. Codeforces Gym 100286G Giant Screen 水题

    Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...

  7. codeforces 710A A. King Moves(水题)

    题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include ...

  8. codeforces 659A A. Round House(水题)

    题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...

  9. CodeForces 489B BerSU Ball (水题 双指针)

    B. BerSU Ball time limit per test 1 second memory limit per test 256 megabytes input standard input ...

随机推荐

  1. Android Framework 记录之一

    简介 之前的研究太偏向应用层功能实现了,很多原理不了解没有深究,现在研究framework框架层了. 记录 1.下载源码,目录如下: 2.Android系统的层次如下: 3.项目目录简单分析如下: 4 ...

  2. jmeter源码编译

    转载:http://blog.csdn.net/wanglha/article/details/42004943 一.下载源码 git clone git://github.com/apache/jm ...

  3. POJ3114 有些图缩点/改图/最短路

    没想到手感还在~ 不须要又一次建图.仅仅要依据条件改改权值就可以. 还跑k次SPFA~ #include<cstdio> #include<iostream> #include ...

  4. 转: 基于netty+ protobuf +spring + hibernate + jgroups开发的游戏服务端

    from: http://ybak.iteye.com/blog/1853335 基于netty+ protobuf +spring + hibernate + jgroups开发的游戏服务端 游戏服 ...

  5. python的私有化

    1.双下划线(__) 由双下划线開始的属性在执行时被混淆,所以直接訪问是不同意的.实际上以双下划线開始的属性 会在解释时在前面加上下划线和类名.如self.__num会被解析为self._classN ...

  6. C#向Sql数据库插入空值的控制

    string name = textBox1.Text; int age = Convert.ToInt32(textBox2.Text.Trim()); ? null : (int?)Convert ...

  7. Quality control

    定义测试         为测试添加测试项     测试项目按类型分2种 Qualitative 定性,描述类的,比如颜色,是,否 Quantitative 定量,有明确的衡量         定性 ...

  8. 广告制胜无它,顺应人性尔——leo鉴书63

    近期看了几本怎样写文案的书.对广告有了些兴趣.查了下相关销量排行,位置比較高的是本叫<科学的广告+我的广告生涯>的书,是同一作者(Claude C. Hopkins)两本书的合集.前者是他 ...

  9. 关于finfo_file函数获取文件mime值验证出错的问题

    今天在做图片上传 验证图片mime值时 突然发现  个别特殊情况下finfo_file 获取的MIME值不能直接使用, 依照官方的写法是 $finfo=finfo_open(FILEINFO_MIME ...

  10. python(4)- 简单练习:python实现购物车的优化

    购物车程序优化题目要求: 1. 用户退出时打印商品列表时,按以下格式 -------您购买的商品如下------ id    商品    数量    单价    总价 1      iPhone 2  ...