传送门:http://codeforces.com/problemset/problem/614/B
此题目刚看的时候并没有理解他的精华在哪里,主要原因就是没有注意到题目中加粗的字符,即每个数中1最多只有1个,而且只有1个非beautiful数!
刚开始被高精度带偏了,这类题肯定就是用string嘛,最后答案的形式就是那个非beautiful数,后面跟的都是0,所以说将一个string初值置为“1”,然后如果遇到不是1的前缀更新,最后输出就可以了,很优美的代码!
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n;
int main(){
cin>>n;
int c=0;
string t,b="1";
for(int i=1;i<=n;i++){
cin>>t;
if(t=="0") return puts("0");
while(t[t.size()-1]=='0') c++,t=t.substr(0,t.size()-1);
if(b=="1") b=t;
}
cout<<b;
while(c--) cout<<"0";
cout<<endl;
return 0;
}