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 ...
随机推荐
- Linux安装初始化
鸟哥的Linux 私房菜 Linux常用命令大全 http://www.cnblogs.com/yjd_hycf_space/p/7730690.html 安装看锋哥教程 可能最后网卡出错 ...
- Becoming inspired - ASC - 2017 MARCH 24
Becoming inspired - The 11 questions to ask yourself when you feel uninspired @ Advanced Studio Clas ...
- intelij创建MapReduce工程
1.创建一个maven工程 2.POM文件 <?xml version="1.0" encoding="UTF-8"?><project xm ...
- mysql 中文编码问题
- 疯狂JAVA——第四章 流程控制与数组
4.5 数组类型 数组也是一种类型.它本身是引用类型.例如int是一种基本类型,int[]就是引用类型. 两种定义数组的方式: 1.type[] arrayName; 2.type arrayName ...
- 利用R产生随机数
生成随机数有两个函数runif()和rnorm(),其中r表示的是random随机的意思,unif表示的是均匀分布,而norm表示的是正态分布. 1)生成10个2到3之间的,服从均匀分布的随机数:ru ...
- git的一些常用操作命令
这些操作命令都是从廖雪峰老师的官网上看过后记下来的,以下是廖雪峰老师的官网,大家可以看看,教程不错~ http://www.liaoxuefeng.com/wiki/00137395163059296 ...
- Python staticmethod() 函数
Python staticmethod() 函数 Python 内置函数 python staticmethod 返回函数的静态方法. 该方法不强制要求传递参数,如下声明一个静态方法: class ...
- In case of failure
In case of failure http://acm.hdu.edu.cn/showproblem.php?pid=2966 Time Limit: 60000/30000 MS (Java/O ...
- 7-掉馅饼(数组dp)
/* 免费馅饼 时间限制:1000 ms | 内存限制:65535 KB ...