codeforces 664A A. Complicated GCD(水题)
题目链接:
1 second
256 megabytes
standard input
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!
The only line of the input contains two integers a and b (1 ≤ a ≤ b ≤ 10100).
Output one integer — greatest common divisor of all integers from a to b inclusive.
1 2
1
61803398874989484820458683436563811772030917980576 61803398874989484820458683436563811772030917980576
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(水题)的更多相关文章
- 【Codeforces 664A】 Complicated GCD
[题目链接] 点击打开链接 [算法] gcd(a,a+1) = 1 所以当a = b时,答案为a,否则为1 [代码] #include<bits/stdc++.h> using names ...
- codeforces 577B B. Modulo Sum(水题)
题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树
A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...
- codeforces 696A Lorenzo Von Matterhorn 水题
这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...
- CodeForces 589I Lottery (暴力,水题)
题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...
- Codeforces Gym 100286G Giant Screen 水题
Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...
- codeforces 710A A. King Moves(水题)
题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include ...
- codeforces 659A A. Round House(水题)
题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...
- CodeForces 489B BerSU Ball (水题 双指针)
B. BerSU Ball time limit per test 1 second memory limit per test 256 megabytes input standard input ...
随机推荐
- Engine中如何进行七参数投影转换?
来自:http://zhihu.esrichina.com.cn/?/question/6858 解决办法]:首先创建自定义geotransformation,然后用IGeometry.Project ...
- 织梦dedecms 去掉后台登陆验证码的方法
那么有什么办法解决呢? 那么现在就给大家解决织梦去掉后台登陆验证码. 这里面分两种版本 一个是织梦5.6的程序 那么织梦5.6程序的解决办法是: 在织梦DedeCms5.6版本可以通过下面路径对验 ...
- [转] RabbitMQ介绍
转自: http://lynnkong.iteye.com/blog/1699684 1 什么是RabbitMQ? RabbitMQ是实现AMQP(高级消息队列协议)的消息中间件的一种,最初 ...
- log4j:WARN Please initialize the log4j system properly解决的方法
要解决问题很easy,建立LOG4J 的配置文件就可以. 在src 文件夹下创建配置文件,选 一.择菜单File > New > File,文件名称输入log4j.properties,文 ...
- 关于CUDA两种API:Runtime API 和 Driver API
CUDA 眼下有两种不同的 API:Runtime API 和 Driver API,两种 API 各有其适用的范围. 高级API(cuda_runtime.h)是一种C++ ...
- PHP compact() 函数
Compact ---- 创建一个包含变量名和它们的值的数组: <?php $firstname = "Bill"; $lastname = "Gates" ...
- 点击选中/取消选中flag
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name ...
- Android学习系列(二)布局管理器之线性布局的3种实现方式
转载请注明出处:http://blog.csdn.net/lhy_ycu/article/details/39643669 LinearLayout是Android控件中的线性布局控件,它包括的子控件 ...
- linux查看磁盘信息
linux查看磁盘挂载信息:df -hlinux查看文件夹大小:sudo du -h --max-depth=1
- open-source Julius speech-recognition engine
http://julius.osdn.jp/en_index.php?q=index-en.html Open-Source Large Vocabulary CSR Engine Julius ht ...