您的位置:首页 > 编程语言 > C语言/C++

boj 1328 简单问题 不过要考虑输入大小 long long可以 不过VC++不能编译

2011-03-16 12:48 627 查看
agicpig and Acm like to compete with each other recently. 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.

Input
The input consists of one or more lines. Each line contains a positive integer n.A line which contains a single 0 will end the input.

Output
A positive integer on each line denoting the required answer.

Sample Input

2
5
10
13
0

Sample Output

1
3
5
7

#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
long long a[10000],b,j; //vc下不行 不过acm可以;
int i=0,k=0;
while(cin>>b)
{
j=b;
if(b==0)
break;
else
{
if(j%2==0)
a[i]=j/2;
if(j%2==1)
a[i]=j/2+1;

}
i++;
}
for(j=0;j<i;j++)
cout<<a[j]<<endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐