A-B Game

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Description

Fat brother and Maze are playing a kind of special (hentai) game by two integers A and B. First Fat brother write an integer A on a white paper and then Maze start to change this integer. Every time Maze can select an integer x between 1 and A-1 then change A into A-(A%x). The game ends when this integer is less than or equals to B. Here is the problem, at least how many times Maze needs to perform to end this special (hentai) game.

Input

The first line of the date is an integer T, which is the number of the text cases.

Then T cases follow, each case contains two integers A and B described above.

1 <= T <=100, 2 <= B < A < 100861008610086

Output

For each case, output the case number first, and then output an integer describes the number of times Maze needs to perform. See the sample input and output for more details.

Sample Input

2 5 3 10086 110

Sample Output

Case 1: 1 Case 2: 7
 #include <stdio.h>
#include <string.h>
int main()
{
int T;
int ca=;
int i,j,k;
long long a,b;
scanf("%d",&T);
while(T--)
{
int num=;
scanf("%I64d %I64d",&a,&b);
while(a>b)
{
a=a/+;
num++;
}
printf("Case %d: %d\n",ca,num);
ca++;
}
return ;
}

FZU 2147 A-B Game的更多相关文章

  1. FZU 2147 A-B Game(数学)

    我们只需要知道这个取完模最大是 a / 2 + 1就可以了,不过超时了几次,换了visual C++才过,oj还真是傲娇啊. #include<iostream> #include< ...

  2. FZU 2137 奇异字符串 后缀树组+RMQ

    题目连接:http://acm.fzu.edu.cn/problem.php?pid=2137 题解: 枚举x位置,向左右延伸计算答案 如何计算答案:对字符串建立SA,那么对于想双延伸的长度L,假如有 ...

  3. FZU 1914 单调队列

    题目链接:http://acm.fzu.edu.cn/problem.php?pid=1914 题意: 给出一个数列,如果它的前i(1<=i<=n)项和都是正的,那么这个数列是正的,问这个 ...

  4. ACM: FZU 2105 Digits Count - 位运算的线段树【黑科技福利】

     FZU 2105  Digits Count Time Limit:10000MS     Memory Limit:262144KB     64bit IO Format:%I64d & ...

  5. codev 2147 数星星

    2147 数星星 http://codevs.cn/problem/2147/ 题目描述 Description 小明是一名天文爱好者,他喜欢晚上看星星.这天,他从淘宝上买下来了一个高级望远镜.他十分 ...

  6. FZU 2112 并查集、欧拉通路

    原题:http://acm.fzu.edu.cn/problem.php?pid=2112 首先是,票上没有提到的点是不需要去的. 然后我们先考虑这个图有几个连通分量,我们可以用一个并查集来维护,假设 ...

  7. ACM: FZU 2107 Hua Rong Dao - DFS - 暴力

    FZU 2107 Hua Rong Dao Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I6 ...

  8. ACM: FZU 2112 Tickets - 欧拉回路 - 并查集

     FZU 2112 Tickets Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u P ...

  9. ACM: FZU 2102 Solve equation - 手速题

     FZU 2102   Solve equation Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & ...

随机推荐

  1. 使用sysprep克隆虚拟机

    1.虚拟机安装windows2008 x64 r2 2.安装完毕后,运行”c:\windows\system32\sysprep\sysprep.exe” 3.选择”进入系统全新体验(OOBE),勾选 ...

  2. How to change Jenkins default folder on Windows?

    http://stackoverflow.com/questions/12689139/how-to-change-jenkins-default-folder-on-windows accepted ...

  3. 薛非《品悟C-抛弃C程序设计中的谬误与恶习》读后感part1【转】

    薛非<品悟C-抛弃C程序设计中的谬误与恶习>读后感part1 作者:宝贝孙秀楠﹣大连程序员 发表于2012年10月5日由admin 出处:http://sunxiunan.com/?p=2 ...

  4. ipseccmd命令解析

    IPSec 首先需要指出的是,IPSec和TCP/IP筛选是不同的东西,大家不要混淆了.TCP/IP筛选的功能十分有限,远不如IPSec灵活和强大.下面就说说如何在命令行下控制IPSec. XP系统用 ...

  5. tomcat支持的websocket服务

    首发:个人博客 在tomcat7之后的版本,写个websocket服务程序非常容易——如以下代码所示,当客户端建立了一个连接并发送了一些什么内容到服务器,服务器将每隔两秒返回一个字符串“world”. ...

  6. scala一些高级类型

    package com.ming.test import scala.collection.mutable.ArrayBuffer import scala.io.Source import java ...

  7. iOS使用静态变量

    之前看"Effective Objective-C 2.0", 第4条, 多用静态变量, 少用define. 正好我的项目有些东西是静态变量, 之前java我习惯起一个类, 里面全 ...

  8. 修改ecshop让订单详情里将会员地址详情全部显示

    $sql = "SELECT concat(IFNULL(c.region_name, ''), '  ', IFNULL(p.region_name, ''), " . &quo ...

  9. linux中利用awk对数组进行排序

    数组 在排序前需要对数组有所了解,数组是用于存储一系列值得变量,这些值之间通常是由联系的,可通过索引来访问数组的值,索引需要用括号括起来,基本格式如下: array[index]=value awk数 ...

  10. JavaScript脚本语言基础(三)

    导读: 数学对象(Math) 数组对象(Array) 字符串对象(String) 日期对象(Date) js对象是属性和方法的集合.JavaScript中的所有事物都是对象,如:字符串.数值.数组.函 ...