Head-to-Head Match


Time Limit: 2 Seconds      Memory Limit: 65536 KB

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

题意:两两比赛,胜出一人,胜者进入下一轮比赛。如果该轮总数是奇数,则随机选出一人直接参加下一轮比赛,求比赛总轮数。

 #include <iostream>
#include <cmath>
using namespace std;
int main(){
int n;
while(cin >> n){
if(n == )
break;
for(double i = ; i < ; i++){
//pow函数的参数需要定义为double类型
if(pow(, i) >= n){
cout << i << endl;
break;
}
}
}
return ;
}

zoj 2722 Head-to-Head Match(两两比赛)的更多相关文章

  1. zoj 2722 Head-to-Head Match(数学思维)

    题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2722 题目描述: Our school is planning ...

  2. 两两组合覆盖测试用例设计工具:PICT

    两两组合覆盖测试用例设计工具:PICT 2016-08-31 目录 1 成对测试简介2 PICT使用  2.1 安装 PICT  2.2 使用PICT3 PICT算法  3.1 准备阶段  3.2 产 ...

  3. 最近两场比赛 CF 285 & TC 646

    Codeforces 285 这场rating又掉了,好在只掉了十多. 题目比较水,但是我比赛时居然只艰辛地过了前两道. 504A 由于图是森林,所以一定有度为1的点,把这些点删了后图还是森林.然后就 ...

  4. [LeetCode] Couples Holding Hands 两两握手

    N couples sit in 2N seats arranged in a row and want to hold hands. We want to know the minimum numb ...

  5. [LeetCode] 24. 两两交换链表中的节点

    题目链接:https://leetcode-cn.com/problems/swap-nodes-in-pairs/ 题目描述: 给定一个链表,两两交换其中相邻的节点,并返回交换后的链表. 你不能只是 ...

  6. [Swift]LeetCode24. 两两交换链表中的节点 | Swap Nodes in Pairs

    Given a linked list, swap every two adjacent nodes and return its head. Example: Given 1->2->3 ...

  7. 两两交换链表中的节点(java实现)

    题目: 给定一个链表,两两交换其中相邻的节点,并返回交换后的链表. 你不能只是单纯的改变节点内部的值,而是需要实际的进行节点交换. 示例: 给定 1->2->3->4, 你应该返回 ...

  8. 机器学习-文本数据-文本的相关性矩阵 1.cosing_similarity(用于计算两两特征之间的相关性)

    函数说明: 1. cosing_similarity(array)   输入的样本为array格式,为经过词袋模型编码以后的向量化特征,用于计算两两样本之间的相关性 当我们使用词频或者TFidf构造出 ...

  9. hdu 5072 两两(不)互质个数逆向+容斥

    http://acm.hdu.edu.cn/showproblem.php?pid=5072 求n个不同的数(<=1e5)中有多少组三元组(a, b, c)两两不互质或者两两互质. 逆向求解,把 ...

随机推荐

  1. eclipse快捷键,移动和复制一段代码

    移动代码:alt+上或下箭头 复制加移动代码:ctrl + alt + 上或下箭头

  2. PKU_campus_2018_H Safe Upper Bound

    思路: 题目链接http://poj.openjudge.cn/practice/C18H/ 用2147483647除以最大素因子. 这里用了Pollard_rho因子分解算法,模板参考了http:/ ...

  3. js深拷贝与浅拷贝的区别及实现

    1. 对于基本数据类型 其值在内存中占据着固定大小的空间,并被保存在栈内存中.当一个变量向另一个变量复制基本类型的值,会创建这个值的副本,并且我们不能给基本数据类型的值添加属性.其为深拷贝. 2. 对 ...

  4. webuploader上传工具

    http://fex.baidu.com/webuploader/getting-started.html#显示用户选择 Html部分 首先准备dom结构,包含存放文件信息的容器.选择按钮和上传按钮三 ...

  5. HALCON算子1

    https://blog.csdn.net/think_fast/article/details/7011364 待验证学习

  6. Mysql is not allowed to connect mysql server

    1.     mysql -u root -p 2.    select host from user where user='root';      //可以看到当前主机配置信息为localhost ...

  7. Python 使用re模块实现正则表达式

    # coding: utf-8 # Team : Quality Management Center # Author:Carson # Date :2019/6/21 10:41 # Tool :P ...

  8. docker 搭建 Java Web 运行环境

    安装环境:jdk,tomcat,mysql,nginx

  9. instance of type of object.prototype.tostring 区别

    typeof typeof 是一个操作符,其右侧跟一个一元表达式,并返回这个表达式的数据类型.   返回的结果用该类型的字符串(全小写字母)形式表示,包括以下 6 种:   number.boolea ...

  10. 三大框架所使用的UI框架