zoukankan      html  css  js  c++  java
  • 1653: Champion of the Swordsmanship

    1653: Champion of the Swordsmanship

    Time Limit: 1 Sec  Memory Limit: 64 MB
    Submit: 11  Solved: 8
    [Submit][Status][Web Board]

    Description

    In Zhejiang University, there is a famous BBS named Freecity. Usually we call it 88.

    Recently some students at the Humour board on 88 create a new game - Swordsmanship. Different from the common sword fights, this game can be held with three players playing together in a match. Only one player advances from the match while the other two are eliminated. Sometimes they also hold a two-player match if needed, but they always try to hold the tournament with as less matches as possible.

    最近,一些学生在幽默板上创造了一个新的游戏——剑术。与普通的剑战不同,这款游戏可以与三名玩家在一场比赛中一起玩。只有一名球员在比赛中取得进步,而另外两名则被淘汰。有时,如果需要的话,他们也会举办双人赛,但他们总是尽量少赛。

    Input

    The input contains several test cases. Each case is specified by one positive integer n (0 < n < 1000000000), indicating the number of players. Input is terminated by n=0.

    Output

    For each test case, output a single line with the least number of matches needed to decide the champion.

    Sample Input

    3
    4
    0

    Sample Output

    1
    2


    #include<stdio.h>
    int main()
    {
        int n,m,k;
        while(scanf("%d",&n)&&n!=0)
        {
            if(n%2==0)
                printf("%d\n",n/2);
            else
                printf("%d\n",(n-1)/2);
        }
    }
    

      

     
  • 相关阅读:
    p67 把特定位置的位变成0,进行与运算
    p65 逻辑与运算
    JavaScript对象和初始面向对象
    JavaScript操作DOM对象
    JavaScript操作BOM对象
    JavaScript基础
    DAO模式
    使用ADO.NET访问数据库
    连接查询和分组查询
    模糊查询和聚合函数
  • 原文地址:https://www.cnblogs.com/mjn1/p/8435754.html
Copyright © 2011-2022 走看看