CodeForces 664A Complicated GCD
来源:互联网 发布:tenga iroha 知乎 编辑:程序博客网 时间:2024/05/28 09:32
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
1 2
1
61803398874989484820458683436563811772030917980576 61803398874989484820458683436563811772030917980576
61803398874989484820458683436563811772030917980576
Source
如果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;}
- CodeForces 664A Complicated GCD
- CodeForces 664A Complicated GCD
- 664A - Complicated GCD
- CodeForces - 664A Complicated GCD (技巧)水
- A. Complicated GCD
- Codeforces Round #347 (Div. 2) A. Complicated GCD
- Codeforces Round #347 (Div. 2) A - Complicated GCD
- Codeforces Round #347 (Div. 2)-Complicated GCD(字符串判等)
- Codeforces 582A GCD Table
- codeforces 582A GCD Table
- Codeforces 582A:GCD Table
- codeforces 582A GCD Table
- codeforces A.pride 数学题 gcd
- Codeforces 583C/582A 暴力+gcd
- Codeforces-891A Pride(GCD&&思维)
- Codeforces 811B Vladik and Complicated Book
- codeforces#416 div2- Vladik and Complicated Book
- Codeforces 811 B Vladik and Complicated Book
- K-Means算法的C语言实现
- 献给和我合作的过得前端童靴们:jquery源码分析--核心函数(创建选择器筛选document元素)
- win8下安装wamp的各种问题
- Java:普通代码块、构造代码块、静态代码块
- 第八周项目1-数组做数据成员(2)
- CodeForces 664A Complicated GCD
- C++编程基础笔记章节七
- 不用加减乘除实现加法
- iOS开发之即时通讯之Socket(AsyncSocket)
- [LeetCode]137. Single Number II
- 《iOS Human Interface Guidelines》——Template Icons
- View事件体系(一)基础概念
- tomcat启动报加载mvc-dispatcher-servlet.xml失败错误
- 线程同步