zoj 2722 Head-to-Head Match(两两比赛)
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(两两比赛)的更多相关文章
- zoj 2722 Head-to-Head Match(数学思维)
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2722 题目描述: Our school is planning ...
- 两两组合覆盖测试用例设计工具:PICT
两两组合覆盖测试用例设计工具:PICT 2016-08-31 目录 1 成对测试简介2 PICT使用 2.1 安装 PICT 2.2 使用PICT3 PICT算法 3.1 准备阶段 3.2 产 ...
- 最近两场比赛 CF 285 & TC 646
Codeforces 285 这场rating又掉了,好在只掉了十多. 题目比较水,但是我比赛时居然只艰辛地过了前两道. 504A 由于图是森林,所以一定有度为1的点,把这些点删了后图还是森林.然后就 ...
- [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 ...
- [LeetCode] 24. 两两交换链表中的节点
题目链接:https://leetcode-cn.com/problems/swap-nodes-in-pairs/ 题目描述: 给定一个链表,两两交换其中相邻的节点,并返回交换后的链表. 你不能只是 ...
- [Swift]LeetCode24. 两两交换链表中的节点 | Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head. Example: Given 1->2->3 ...
- 两两交换链表中的节点(java实现)
题目: 给定一个链表,两两交换其中相邻的节点,并返回交换后的链表. 你不能只是单纯的改变节点内部的值,而是需要实际的进行节点交换. 示例: 给定 1->2->3->4, 你应该返回 ...
- 机器学习-文本数据-文本的相关性矩阵 1.cosing_similarity(用于计算两两特征之间的相关性)
函数说明: 1. cosing_similarity(array) 输入的样本为array格式,为经过词袋模型编码以后的向量化特征,用于计算两两样本之间的相关性 当我们使用词频或者TFidf构造出 ...
- hdu 5072 两两(不)互质个数逆向+容斥
http://acm.hdu.edu.cn/showproblem.php?pid=5072 求n个不同的数(<=1e5)中有多少组三元组(a, b, c)两两不互质或者两两互质. 逆向求解,把 ...
随机推荐
- req.getParameter()无法获取参数(附前端json序列化)
问题:前端用Ajax的post方式想servlet传递参数,servlet的getParameter()方法无法获取参数. 前端代码: $.ajax({ url: '/TestWeb/addBook' ...
- js 判断客户端系统
function detectOS() { var sUserAgent = navigator.userAgent; var isWin = (navigator.platform == " ...
- Webform 内置对象2(Session、Application)、Repeater的Command操作
内置对象: 1.Session:跟Cookies一样用来存储用户数据,但保存位置不同,保存在服务器内存上 每一台电脑访问服务器,都会是独立的一套session,key值都一样,但是内容都是不一样的 S ...
- AJPFX总结Collection集合(上)
出现集合类的原因 面向对象语言对事物的体现都是以对象的形式,所以为了方便对多个对象的操作,就对对象进行存储,集合就是存储对象最常用的一个方式. 数组和集合都是容器有何不同? 数组虽也可存储对象,但长度 ...
- UVa OJ 494
Kindergarten Counting Game Everybody sit down in a circle. Ok. Listen to me carefully. ``Woooooo, ...
- iOS infoq资料架构设计漫谈
http://www.infoq.com/cn/ios/?utm_source=infoq&utm_medium=header_graybar&utm_campaign=topic_c ...
- IOS之pageControl
用户点击页面控件,会触发UIControlEventValueChanged事件,并启动设置为控件动作的任何方法.可以通过调用currentPage查询控件的新值,并通过调整numberOfPages ...
- ie 导出不行,不兼容问题,或只出现后缀文件无法识别
// 下载模板 @RequestMapping("/download") @ResponseBody public ResponseEntity<byte[]> dow ...
- 在ubuntun虚拟机里安装goLang语言编程环境
Go语言是谷歌2009发布的第二款开源编程语言. Go语言专门针对多处理器系统应用程序的编程进行了优化,使用Go编译的程序可以媲美C或C++代码的速度,而且更加安全.支持并行进程. 北京时间2010年 ...
- CFBundleURLTypes URL scheme
https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Ar ...