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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值