Last Defence (2014 西安现场赛)
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=94237#problem/K
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu
Given two integers A and B. Sequence S is defined as follow:
• S0 = A
• S1 = B
• Si = |Si−1 − Si−2| for i ≥ 2
Count the number of distinct numbers in S.
Input
The first line of the input gives the number of test cases, T. T test cases follow. T is about 100000.
Each test case consists of one line — two space-separated integers A, B. (0 ≤ A, B ≤ 1018).
Output
For each test case, output one line containing ‘Case #x: y’, where x is the test case number (starting
from 1) and y is the number of distinct numbers in S.
Sample Input
2
7 4
3 5
Sample Output
Case #1: 6
Case #2: 5
#include<stdio.h> int main()
{
long long t, iCase=;
scanf("%lld", &t);
while(t--)
{
long long a, b, sum=, k, t; scanf("%lld%lld", &a, &b); if(a<b)
t=a, a=b, b=t; if(a== && b==)
{
printf("Case #%lld: 1\n", iCase++);
continue;
}
else if(b==)
{
printf("Case #%lld: 2\n", iCase++);
continue;
} while(a%b!=)
{
sum += a/b;
k = a;
a = b;
b = k%b;
} sum += a/b; printf("Case #%lld: %lld\n", iCase++, sum+);
}
return ;
}
Last Defence (2014 西安现场赛)的更多相关文章
- 2014西安现场赛F题 UVALA 7040
地址 题意:求在m种颜色中挑选k种颜色,给n个花朵涂色有几种方法. 分析:画图可以发现,基本的公式就是k ×(k-1)^(n-1).但这仅保证了相邻颜色不同,总颜色数不超过k种,并没有保证恰好出现k种 ...
- CF GYM100548 (相邻格子颜色不同的方案数 2014西安现场赛F题 容斥原理)
n个格子排成一行,有m种颜色,问用恰好k种颜色进行染色,使得相邻格子颜色不同的方案数. integers n, m, k (1 ≤n, m ≤ 10^9, 1 ≤ k ≤ 10^6, k ≤ n, m ...
- 2020 ICPC EC Final西安现场赛游记
也不知道从何说起,也不知道会说些什么,最想表达的就是很累很累. 从第一天去的时候满怀希望,没什么感觉甚至还有一些兴奋.到后来一直在赶路,感觉很疲惫,热身赛的时候觉得马马虎虎,导致热身赛被咕.然后教练就 ...
- hdu 5078 2014鞍山现场赛 水题
http://acm.hdu.edu.cn/showproblem.php?pid=5078 现场最水的一道题 连排序都不用,由于说了ti<ti+1 //#pragma comment(link ...
- hdu 5073 Galaxy(2014 鞍山现场赛)
Galaxy Time Limit: 2000/1000 MS (J ...
- hdu 5071(2014鞍山现场赛B题,大模拟)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5071 思路:模拟题,没啥可说的,移动的时候需要注意top的变化. #include <iostr ...
- zoj 3820(2014牡丹江现场赛B题)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5374 思路:题目的意思是求树上的两点,使得树上其余的点到其中一个点的 ...
- 2014 牡丹江现场赛 A.Average Score(zoj 3819) 解题报告
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5373 题目意思: 有两个class:A 和 B,Bob 在 Clas ...
- 2014 牡丹江现场赛 i题 (zoj 3827 Information Entropy)
I - Information Entropy Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %l ...
随机推荐
- 迷你MVVM框架 avalonjs 学习教程14、事件绑定
之前的章节许多示例代码也或多或少地展示了如何使用ms-click来绑定事件了.能直接在模板上绑定是事件,这也是静态模板与动态绑定的一大区别.ms-click不是简单的onclick的别名,它在内部屏蔽 ...
- HTTP 和 Socket 区别
要弄明白 http 和 socket 首先要熟悉网络七层:物 数 网 传 会 表 应,如图1 如图1 HTTP 协议:超文本传输协议,对应于应用层,用于如何封装数据. TCP/UDP 协议:传输控制协 ...
- InnoDB FULLTEXT
1.概要 InnoDB引擎对FULLTEXT索引的支持是MySQL5.6新引入的特性,之前只有MyISAM引擎支持FULLTEXT索引.对于FULLTEXT索引的内容可以使用MATCH()…AGAIN ...
- Treasures and Vikings(两次搜索)
Treasures and Vikings https://www.luogu.org/problemnew/show/P4668 题意翻译 你有一张藏宝图,藏宝图可视为 N×MN×M 的网格.每个格 ...
- Maven项目的拆分与聚合
---------------------siwuxie095 Maven 项目的拆分与聚合 1.对已有的 Ma ...
- ftp指令集
想进行ftp相关编程,得了解ftp的指令集. 可参考:http://blog.csdn.net/weiyuefei/article/details/51758288 ftp的命令和指令集不同: 命令是 ...
- [leetcode]29. Divide Two Integers 两整数相除
Given two integers dividend and divisor, divide two integers without using multiplication, division ...
- 4-js 函数
总是有些奇奇怪怪的问题: <div> <p class="productStatus"> <span>成交量 <em>${goods ...
- php5.4 trait 理解与学习
Trait 是 php5.4引入的新特性,手册上说的一大段没看懂,这里直接来过来. Trait 是为类似 PHP 的单继承语言而准备的一种代码复用机制.Trait 为了减少单继承语言的限制,使开发人员 ...
- vsftp 500 OOPS: cannot change directory:/home/xyp
1.在linux终端下输入: > setsebool ftpd_disable_trans 1 (*如果出现Could not change active booleans: Invalid b ...