WOJ1035-BG

来源:互联网 发布:阿里云邮客户端 编辑:程序博客网 时间:2024/04/27 13:58

Magicpig and Acm like to compete with each other recently, and the loser has to "BG" the winner, that means, if Magicpig wins, Acm will treat him to a meal. But Acm is so powerful that Magicpig has to "BG" him almost every time. Everybody is very interested in this. So more and more ACMers are attracted to participate in this game.

One day, Peipei said: "It is unfair that one person should 'BG' all the others. I suggest that 50% of the participants should pay the bill. That means, if there are n participants, then Ceil(n/2) person should 'BG' the other n-Ceil(n/2) person." This is a good idea! So all of us agree to do so. This is the story of "BG".


Now you task is: given a number n -- the total number of participants, you have to calculate how many people should pay the bill.

输入格式

The input consists of one or more lines.
Each line contains a positive integer n (2 <= n <= 100).
A line which contains a single 0 will end the input, and should not be processed.

输出格式

A positive integer on each line denoting the required answer.

样例输入

2510130

样例输出

135

7

问一个数除2向上取整是多少,可以用ceil,有个简单的方法就是把n加1直接除2

#include<stdio.h>#include<math.h>int main() {int n;while(1) {scanf("%d",&n);if(n==0)break;printf("%d\n",(int)ceil(((double)n)/2.0));}return 0;}