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)两两不互质或者两两互质. 逆向求解,把 ...
随机推荐
- PT2264解码心得
PT2264解码心得 最近闲暇时间在琢磨无线RF解码程序,正好在数码之家论坛中翻出大佬的解码程序(http://bbs.mydigit.cn/read.php?tid=245739),于是乎,慢慢学习 ...
- cocos_js写文件
var writablePath = jsb.fileUtils.getWritablePath(); writablePath += "cocos/data/"; var fil ...
- Xml文档数据提取到Excel表中
近期,财务一位同事,吐槽:<某XX开票软件>导出数据文档只有Xml格式,竟然没有Excel文档,工作起来非常不方便,希望我想想办法.上图: 需求分析:Xml数据----> 提取到Da ...
- python2和python3的区别(转)
基本语法差异 核心类差异 Python3对Unicode字符的原生支持 Python2中使用 ASCII 码作为默认编码方式导致string有两种类型str和unicode,Python3只支持uni ...
- CF749D Leaving Auction
题目链接: http://codeforces.com/problemset/problem/749/D 题目大意: 一场拍卖会,共n个买家.这些买家共出价n次,有的买家可能一次都没有出价.每次出价用 ...
- 安卓自定义View教程目录
基础篇 安卓自定义View基础 - 坐标系 安卓自定义View基础 - 角度弧度 安卓自定义View基础 - 颜色 进阶篇 安卓自定义View进阶 - 分类和流程 安卓自定义View进阶 - Canv ...
- oss图片上传失败
在生产上跑的正常代码,新搭了个测试环境,发现oss上传失败! 开始分析oss是否有以各种类似于白名单的功能,不认识测试域名导致的...结果不是! 改变访问类型 因为oss节点Endpoint是在杭州, ...
- Proteus与Keil连接及其仿真(有例子哦!)
记录一下Proteus仿真的一些设置和使用,以方便自己以后复习和大家交流!如有错误,希望大家指正. 1.Proteus软件的安装,这里就不作说明了.
- Linux OpenGL 实践篇-11-shadow
OpenGL 阴影 在三维场景中,为了使场景看起来更加的真实,通常需要为其添加阴影,OpenGL可以使用很多种技术实现阴影,其中有一种非常经典的实现是使用一种叫阴影贴图的实现,在本节中我们将使用阴影贴 ...
- [整理]ADB命令行学习笔记
global driver# 元素定位driver.find_element_by_id("id") # id定位driver.find_element_by_name(" ...