题目链接:

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. 搭建ELK集群

    环境准备 基础环境介绍 操作系统 部署应用 应用版本号 IP地址 主机名 CentOS 7.4 Elasticsearch/Logstash 6.4.3 192.168.1.1 elk1 CentOS ...

  2. ubuntu18.10安装redis遇到问题

    执行命令apt-get install redis-server 安装遇到的问题 1.出现apt-get被占用情况,用ps -a|grep apt ,杀死存在的apt进程 2.还不行就执行sudo f ...

  3. 6.翻译:EF基础系列---什么是EF中的实体?

    原文地址:http://www.entityframeworktutorial.net/basics/what-is-entity-in-entityframework.aspx EF中的实体就是继承 ...

  4. EF使用MySql DBFirst产品的问题总结

    一.实体数据模型向导->新建连接->更改数据源  找不到MySql Batabase选项. 解决:需求安装以下两个插件(mysql官网都可以找到)(注意版本,后面会讲到) 1.MySql ...

  5. jsp的两个include了解

    在jsp中三大指令(page --  include -- taglib)中有一个 include 然后再三个动作标签中(include -- forward -- param)中也有一个includ ...

  6. Vue+WebSocket+ES6+Canvas 制作「你画我猜」小游戏

    Vue+WebSocket+ES6+Canvas 制作「你画我猜」小游戏 转载 来源:jrainlau 链接:https://segmentfault.com/a/1190000005804860 项 ...

  7. 解决修改css或js文件,浏览器缓存更新问题。

    在搜索引擎中搜索关键字.htaccess 缓存,你可以搜索到很多关于设置网站文件缓存的教程,通过设置可以将css.js等不太经常更新的文件缓存在浏览器端,这样访客每次访问你的网站的时候,浏览器就可以从 ...

  8. odoo开发笔记 -- 异常、错误、警告、提示、确认信息显示

    1.检查业务逻辑中的错误,终止代码执行,显示错误或警告信息: raise osv.except_osv(_('Error!'), _('Error Message.')) 示例代码: #删除当前销售单 ...

  9. github 最新项目快报

    http://www.open-open.com/github/view/github2016-10-17.html

  10. python多线程--Condition(条件对象)

    Condition class threading.Condition(lock=None 这个类实现条件变量对象.条件变量允许一个或多个线程等待,知道它们被另一个线程唤醒. 如果给出了lock参数而 ...