CodeForces 664A Complicated GCD
2016-04-17 12:12
447 查看
Complicated GCD
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,答案只能是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; }
相关文章推荐
- 用纯css改变下拉列表select框的默认样式(转)
- java中的内部类
- iOS入门时常用的一些代码段——tableviewCell重用
- 对web结构的了解
- 对拍
- SQL例子
- [IOS]Core Data Model--Demo3
- 【Win 10 应用开发】三维变换
- 数组的几种简单遍历
- 高德地图显示在fragment中并添加按钮点击事件
- 第八周项目1.3 读入文件,写入文件
- TCP三次握手四次挥手
- 19. Remove Nth Node From End of List
- 由浅入深地分析 写时拷贝(Copy On Write)
- 线程同步
- 每天学习一点Scala03_Scala数据类型
- View事件体系(一)基础概念
- [LeetCode]137. Single Number II
- 视频封装格式之mkv--2
- tomcat启动报加载mvc-dispatcher-servlet.xml失败错误