H
来源:互联网 发布:喜欢下雨天知乎 编辑:程序博客网 时间:2024/03/29 22:36
Description
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 Input
101
11
110010
11010
Hint
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
#include<stdio.h>
#include<string.h>
int main()
{
char a[100100];
int i,j,l;
while(gets(a))
{
l=strlen(a);
for(i=0;i<l;i++)
{
if(a[i]=='0')
{
for(j=i;j<l-1;j++)
a[j]=a[j+1];
break;
}
}
if(i==l)
for(i=0;i<l-1;i++)printf("%c",a[i]);
else for(i=0;i<l-1;i++)printf("%c",a[i]);
printf("\n");
}
}
- h
- h
- h
- ,h
- h
- h
- H
- h
- h
- h
- H
- h
- H
- H
- h
- H
- H
- h
- Scintilla开源库使用指南(编辑器篇) 在C++Builder 环境下
- 用fputs和fgets操作文件-将字符串存储到文件中并从文件中读出
- 服务端处理常用的5种基础策略
- hdu4585 STL水题
- Android异常总结---res\layout\addUser.xml: Invalid file name: must contain only [a-z
- H
- (程序员面试题)链栈的基本操作
- Mysql For Windows安装图解
- c函数之getenv()实例
- 关于CCScale9sprite的问题,使用TexturePacker软件,导入plist文件后BUG
- 算法导论 芯片检测问题之个人看法
- 全排列--递归算法实现
- 【面向对象程序设计常见面试题】虚析构函数(已阅)
- android的ListView