题目链接:

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2722

题目描述:

  Our school is planning to hold a new exciting computer programming contest. During each round of the contest, the competitors will be paired, and compete head-to-head. The loser will be eliminated, and the winner will advance to next round. It proceeds until there is only one competitor left, who is the champion. In a certain round, if the number of the remaining competitors is not even, one of them will be chosed randomly to advance to next round automatically, and then the others will be paired and fight as usual. The contest committee want to know how many rounds is needed to produce to champion, then they could prepare enough problems for the contest.

Input

The input consists of several test cases. Each case consists of a single line containing a integer N - the number of the competitors in total. 1 <= N <= 2,147,483,647. An input with 0(zero) signals the end of the input, which should not be processed.

Output

For each test case, output the number of rounds needed in the contest, on a single line.

Sample Input

8
16
15
0

Sample Output

3
4
4
 /*问题 输入一个1到2147483647的整数,计算并输出两两配对的次数
解题思路 其实就是2的几次方的问题*/
#include<cstdio>
#include<cmath> int main()
{
int n,i;
while(scanf("%d",&n),n != ){
for(i=;i<;i++){
if(pow(,i) >= n){
printf("%d\n",i);
break;
}
}
}
return ;
}

zoj 2722 Head-to-Head Match(数学思维)的更多相关文章

  1. 程序设计中的数学思维函数总结(代码以C#为例)

    最近以C#为例,学习了程序设计基础,其中涉及到一些数学思维,我们可以巧妙的将这些逻辑问题转换为代码,交给计算机运算. 现将经常会使用到的基础函数做一总结,供大家分享.自己备用. 1.判断一个数是否为奇 ...

  2. PJ考试可能会用到的数学思维题选讲-自学教程-自学笔记

    PJ考试可能会用到的数学思维题选讲 by Pleiades_Antares 是学弟学妹的讲义--然后一部分题目是我弄的一部分来源于洛谷用户@ 普及组的一些数学思维题,所以可能有点菜咯别怪我 OI中的数 ...

  3. UVa10025 The ? 1 ? 2 ? ... ? n = k problem 数学思维+规律

    UVa10025 ? 1 ? 2 ? ... ? n = k problem The problem Given the following formula, one can set operator ...

  4. B. Tell Your World(几何数学 + 思维)

    B. Tell Your World time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  5. zoj 2722 Head-to-Head Match(两两比赛)

    Head-to-Head Match Time Limit: 2 Seconds      Memory Limit: 65536 KB Our school is planning to hold ...

  6. zoj 2818 Root of the Problem(数学思维题)

    题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2818 题目描述: Given positive integer ...

  7. ZOJ Saddle Point 数学思维题

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5564   根据它的定义是行最小,列最大. 可以证明鞍点是唯一的. ...

  8. hdu 4710 Balls Rearrangement (数学思维)

    意甲冠军:那是,  从数0-n小球进入相应的i%a箱号.然后买一个新的盒子. 今天的总合伙人b一个盒子,Bob试图把球i%b箱号. 求复位的最小成本. 每次移动的花费为y - x ,即移动前后盒子编号 ...

  9. F. Multicolored Markers(数学思维)

    思维:思维就是将大的矩形放在小矩形里面,让大矩形的宽和长尽量靠近. 很容易得到 (a+b)% i = 0 的话, 保证了大矩形的形成,同时里面表示了两种情况:1, a % i =0, b % i=0; ...

随机推荐

  1. 调用azkaban接口,upload 本地zip文件

    使用azkaban部署任务,可以将job文件打成zip包,通过web页面上传. 如图 但是当我们实践CI持续化部署的时候,要实现自动的部署上线. 这时就要调用azkaban提供的api. 地址如下:h ...

  2. iOS处理视图上同时添加单击与双击手势的冲突问题

    _bgView.userInteractionEnabled = YES; //在cell上添加 bgView,给bgView添加两个手势检测方法 UITapGestureRecognizer *do ...

  3. 调用GOOGLE的TTS实现文字转语音(XE7+小米2)(XE10.1+小米5)

    相关资料: 注意:在手机上必须选安装文字转语音引擎“google Text To Speech”地址:http://www.shouji56.com/soft/GoogleWenZiZhuanYuYi ...

  4. 分形之花篮(Flower Basket)

    这一篇展示的图形与上一篇文章分形之皇冠(Crown)很相似. 核心代码: static void FractalFlowerBasket(const Vector3& vStart, cons ...

  5. Constructor in depth

    There are two types of constructor:Instance Constructor and Type Constructor(or so-called Static Con ...

  6. neo4j CQL 使用

    neo4j CQL 使用 1. create命令 CREATE (emp:Employee) #创建一个emp 员工标签 CREATE (dept:Dept) #部门标签 #Added 1 label ...

  7. vs2017常用快捷键

    项目相关的快捷键 Ctrl + Shift + B = 生成项目 Ctrl + Alt + L = 显示 Solution Explorer(解决方案资源管理器) Ctrl + Shift + A = ...

  8. C# 开源仪表盘库—Agauge App

    1.简介 有个叫A.J.Bauer 的大神在System.Windows.Forms.Control类的基础上建立了一个显示各种仪表盘的类.                   英文版简介:C# Tu ...

  9. [学习笔记]Link-Cut Tree

    我终于理解了 \(LCT\)!!!想不到小蒟蒻有一天理解了!!! 1.[模板]Link Cut Tree 存个板子 #include <bits/stdc++.h> using names ...

  10. 爬虫:Scrapy5 - 选择器Selectors

    当抓取网页时,常见的任务是从HTML源码中提取数据.现有的一些库可以达到这个目的: BeautifulSoup lxml Scrapy 提取数据有自己的一套机制.它们被称作选择器(seletors), ...