codeforces157Div2C

C. Little Elephant and Bits
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

The Little Elephant has an integer a, written in the binary notation. He wants to write this number on a piece of paper.

To make sure that the number a fits on the piece of paper, the Little Elephant ought to delete exactly one any digit from number a in the binary record. At that a new number appears. It consists of the remaining binary digits, written in the corresponding order (possible, with leading zeroes).

The Little Elephant wants the number he is going to write on the paper to be as large as possible. Help him find the maximum number that he can obtain after deleting exactly one binary digit and print it in the binary notation.

Input

The single line contains integer a, written in the binary notation without leading zeroes. This number contains more than 1 and at most105 digits.

Output

In the single line print the number that is written without leading zeroes in the binary notation — the answer to the problem.

Sample test(s)
input
101
output
11
input
110010
output
11010
Note

In the first sample the best strategy is to delete the second digit. That results in number 112 = 310.

In the second sample the best strategy is to delete the third or fourth digits — that results in number 110102 = 2610.

 

 

也蛮水的。。就把从高位往下第一个0去掉。。全1的话 随便去一位

不过碰到个小问题。。我想全一的话就最后位不显示 可是输入的时候最后一位好像不是1。。难道是 '\n'  =-=

所以就改成最后第二位不显示 就过了

代码:

 1 #include<stdio.h>
 2 
 3 char arr[100005]={0};
 4 
 5 int main( void)
 6 {
 7     int i=0, j, k;
 8     while( scanf("%c", &arr[i]) != EOF )
 9         i++;
10     for( j=0; j<i; j++)
11     {
12         if( arr[j]=='0')
13         {
14             break;
15         }
16     }
17     if( j==i)
18         j-=2;
19     for( k=0; k<j; k++)
20     {
21             printf("%c", arr[k]);
22     }
23     for( k=j+1; k<i; k++)
24         printf("%c", arr[k]);
25     return 0;
26 }

 

转载于:https://www.cnblogs.com/shadow-justice/archive/2012/12/24/2830680.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值