Gautam and Subhash are two brothers. They are similar to each other in all respects except one. They have different ways of searching. When Gautam has to search for an item from a lot, he goes through all the items one by one and stops when he finds the item. However Subhash has an entirely different and interesting way of searching. However the search works only for items which are sorted. He goes to the middle of the lot, if he finds the desired item, he stops, if not, he checks whether the middle item is smaller or larger than the required item. If larger, he repeats the same process for the first half of the lot, otherwise second half. One day, the two brothers sit in a contest in which they have to find a name out of a sorted dictionary. Whoever finds out the name first will win the contest. The audience is very eager to know who will win and hence they want you to predict.

Input:

The first line of input takes the number of test cases, T.

The next T lines take the total number of names N, followed by M the position of the name to be searched, as well as the amount of time taken for each observation by Gautam G and Subhash S.

Output:

Print 1 in case Gautam will win, 2 in case Subhash will win, 0 in case of a draw in a separate line.

Constraints:

1<=T<=100

1<=N<=1000

1<=M<=N

1<=G<=100

1<=S<=100

Example:

Input:

3
10 8 10 25
10 8 10 30
10 8 10 12

Output:

2
2
2
下面是我的代码实现,C++
#include <iostream>
using namespace std;
int main()
{
    int N;
    cin>>N;
    while(N--)
    {
        int num,index,g,s,gtime,stime;

        cin>>num;
        cin>>index;
        cin>>g;
        cin>>s;

        ,r=num,mid,sci=;
        gtime=index*g;

        while(l<=r)
        {
            mid=(l+r)>>;
            if(mid==index)
            {
                sci++;
                break;
            }
            else if(mid<index)
            {
                sci++;
                l=mid+;
            }
            else
            {
                sci++;
                r=mid-;
            }
        }
        stime=sci*s;
        if(stime>gtime)
            cout<<<<endl;
        else
            cout<<<<endl;

    }
    ;
}

如有问题,请留言

Who Will Win?的更多相关文章

  1. 【Win 10 应用开发】启动远程设备上的应用

    这个功能必须在“红石-1”(build 14393)以上的系统版中才能使用,运行在一台设备上的应用,可以通过URI来启动另一台设备上的应用.激活远程应用需要以下前提: 系统必须是build 14393 ...

  2. Win.ini和注册表的读取写入

    最近在做打包的工作,应用程序的配置信息可以放在注册表文件中,但是在以前的16位操作系统下,配置信息放在Win.ini文件中.下面介绍一下Win.ini文件的读写方法和注册表的编程. 先介绍下Win.i ...

  3. 苹果台式一体机笔记本安装win双系统攻略教程

    步骤 序:win系统下载 :http://www.itellyou.cn 选择要安装的系统进行下载,本文以win7为例   进入苹果系统,左上角——前往——实用工具——BootCamp 助理 点击继续 ...

  4. Win下最爱效率利器:AutoHotKey

    AutoHotkey是一个windows下的开源.免费.自动化软件工具.它由最初旨在提供键盘快捷键的脚本语言驱动(称为:热键),随着时间的推移演变成一个完整的脚本语言.但你不需要把它想得太深,你只需要 ...

  5. Win下必备利器之Cmder

    诚言,对于开发码字者,Mac和Linux果断要比Windows更贴心;但只要折腾下,Windows下也是有不少利器的.之前就有在Windows下效率必备软件一文中对此做了下记载:其虽没oh-my-zs ...

  6. 【Win 10 应用开发】手写识别

    记得前面(忘了是哪天写的,反正是前些天,请用力点击这里观看)老周讲了一个14393新增的控件,可以很轻松地结合InkCanvas来完成涂鸦.其实,InkCanvas除了涂鸦外,另一个大用途是墨迹识别, ...

  7. 【Win 10 应用开发】InkToolBar——涂鸦如此简单

    从WPF开始,就有个InkCanvas控件,封装了数字墨迹处理相关的功能,Silverlight到Win 8 App,再到UWP应用,都有这个控件,所以,老周说了3688遍,凡是.net基础扎实者,必 ...

  8. 【Win 10 应用开发】导入.pfx证书

    这个功能其实并不常用,一般开发较少涉及到证书,不过,简单了解一下还是有必要的. 先来说说制作测试证书的方法,这里老周讲两种方法,可以生成用于测试的.pfx文件. 产生证书,大家都知道有个makecer ...

  9. 【Win 10应用开发】延迟共享

    延迟共享是啥呢,这么说吧,就是在应用程序打开共享面板选择共享目标时,不会设置要共享的数据,而是等到共享目标请求数据时,才会发送数据,而且,延迟操作可以在后台进行. 这样说似乎过于抽象,最好的诠释方法, ...

  10. 【Win 10 应用开发】共享目标(UWP)

    在开始吹牛之前,先给大伙伴们拜个年,祝各位身体健康.生活愉快.[码]到功成. ------------------------------------------------------------- ...

随机推荐

  1. 0:A+B Problem-poj

    0:A+B Problem 总时间限制:  1000ms 内存限制:  65536kB 描述 Calculate a + b 输入 Two integer a,,b (0 ≤ a,b ≤ 10) 输出 ...

  2. 晓莲说-何不原创:如何通过jad把class批量反编译成java文件

    背景:前几天在项目开发的时候遇到一个问题,那就是利用myeclipse编写好的一个项目打包成jar包后上传部署到服务器里,之后本地的项目被自己改来改去出现了一些问题,想着把上传到服务器里面的war包下 ...

  3. POJ 3061 Subsequence 尺取法 POJ 3320 Jessica's Reading Problem map+set+尺取法

    Subsequence Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13955   Accepted: 5896 Desc ...

  4. TL-WR703Nv1.7刷写openwrt固件

    TP-LINK TL-WR703N是一个小型的路由器,可以有线转WiFi,3G转WiFi,很多人拿它刷openwrt系统,然后可以在上面各种搞事. V1.7以前 通常刷openwrt的做法是, 下载一 ...

  5. C# 通过反射初探ORM框架的实现原理

    背景: 以前学的Java进行开发,多用到Mybatis,Hiberante等ORM框架,最近需要上手一个C#的项目,由于不是特别难,也不想再去学习C#的ORM框架,所以就想着用反射简单的实现一下ORM ...

  6. gem install报错

    [root@app-test ruby-2.2.3]# gem install capistrano -v 2.15 ERROR:  While executing gem ... (Gem::Rem ...

  7. PHP开发b2c商城价格

    电商的快速发展不断地挤压传统企业的生存空间,渠道越来越窄,所以现在很多企业开始往线上发展,搭建自己的B2C商城,直接面向消费者进行销售.那开发b2c商城价格怎么样?很多企业都是比较关心到商城价格这个问 ...

  8. windows10版本1709 在桌面和文件中点击右键,会引起卡顿

    windows自动升级到1709版本后出现的问题,而之前是没有这种问题的. 最终解决办法:(需要设置注册表) 运行:快捷键Win+R regedit 路径:可直接复制后粘贴+回车 HKEY_CLASS ...

  9. mysql 基本语法

    ################################################################# #author: 陈月白 #_blogs: http://www.c ...

  10. 多线程编程学习笔记——async和await(二)

    接上文 多线程编程学习笔记——async和await(一) 三.   对连续的异步任务使用await操作符 本示例学习如何阅读有多个await方法方法时,程序的实际流程是怎么样的,理解await的异步 ...