博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
1038. Recover the Smallest Number (30)
阅读量:4151 次
发布时间:2019-05-25

本文共 652 字,大约阅读时间需要 2 分钟。

经典面试题

以下关于该解法正确性的详细证明转自何海涛的博客:

 

#include
#include
#include
#include
using namespace std;bool cmp(string a, string b){ return a+b < b+a;}int main(){ int n; while(scanf("%d",&n)!=EOF) { std::vector
number(n); for(int i = 0; i < n; ++i) cin>>number[i]; //sort sort(number.begin(), number.end(), cmp); //get the first non-zero string ans; for(int i = 0; i < n; ++i) ans += number[i]; int non_zero = -1; for(int i = 0; i < ans.size(); ++i) if(ans[i] != '0') { non_zero = i; break; } if(non_zero == -1) printf("0\n"); else { ans = ans.substr(non_zero); cout<
<

 

 

转载地址:http://paxti.baihongyu.com/

你可能感兴趣的文章
vim 配置
查看>>
openocd zylin
查看>>
cscope数据库生成脚本
查看>>
Ubuntu 10.10输入了正确的用户名密码但是无法登录
查看>>
Eclipse 预览程序 底色
查看>>
保护眼睛 颜色设置
查看>>
splint 编译安装
查看>>
Eclipse 快捷键
查看>>
Doxygen语法
查看>>
Doxygen
查看>>
ubuntu 安装Matlab 解决显示中文乱码
查看>>
ubuntu gvim 菜单栏消失
查看>>
从Cortex - M3过度到Cortex - M4(4)----Cortex-M3、4比较
查看>>
ubuntu matlab simulink 里传函只显示零点为 num(s)
查看>>
eclipse-c-template
查看>>
CHM格式的中文问题
查看>>
C 语言(C99) 对 64 位整数类型的支持
查看>>
链接脚本(1)
查看>>
STM32 出现 hardfault_handler 处理方法
查看>>
代码静态分析工具splint
查看>>