WOJ1035-BG

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.

样例输入

2
5
10
13
0

样例输出

1
3
5

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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值