您的位置:首页 > 其它

Codeforces Round #339 (Div. 2) (B 模拟)

2016-04-25 18:38 417 查看
这道水题明明不难,然而看错题了,据说这道题用高精度和java大数都是过不去的,一定要注意,数据是十万位,不是小于十万,因为只有一个不美丽数也就是说基本都是0,1,只要把0计数,1超过一次单拿出来,非0非1单拿出来,几乎就没问题了有0的状况,和全都是美丽数的情况要单独考虑一下,哎,还是太菜啊

#include <iostream>
#include <string.h>
using namespace std;
char s[100005],p[100005];
int main()
{
int T;
while(cin>>T)
{
bool flag=0;
long long sum0=0,ans=0;
while(T--)
{
long long len=0,sum1=0;
bool flag2=0;
memset(s,0,sizeof(s));
cin>>s;
len=strlen(s);
for(int i=0; i<len; i++)
{
if(s[i]=='0'&&len==1)
{
flag=1;
break;
}
else if(s[i]=='1')
sum1++;
else if(s[i]!='0'&&s[i]!='1')
{
flag2=1;
break;
}
}
if(flag==1)
continue;
else if(sum1>1||flag2==1)
{
strcpy(p,s);
}
else
{
for(int i=0; i<len; i++)
{
if(s[i]=='0')
sum0++;
}
}
}
if(flag==1)
{
cout<<0<<endl;
}
else
{
if(p[0]!=NULL)
{
cout<<p;
}
else
{
cout<<1;
}
for(int i=1; i<=sum0; i++)
cout<<0;
cout<<endl;
}
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  codeforces 水题