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; }
相关文章推荐
- 【HDU 5366】The mook jong 详解
- Codeforces Round #197 (Div. 2)
- Codeforces Round #198 (Div. 1)
- Codeforces 405E Codeforces Round #238 (Div. 2)E
- Codeforces 407C Codeforces Round #239 (Div. 1)C
- HDU 5240 Exam (好水的题)
- CodeForces 449A - Jzzhu and Chocolate
- CodeForces 449 B. Jzzhu and Cities
- codeforces 618C. Constellation
- 北大—1006——Biorhythms
- Codeforces Round #265 (Div. 2)
- Codeforces #310 div2 C. Case of Matryoshkas
- 时间计算(heaven.pas/cpp)
- 工作依赖(job.cpp/pas)
- 题目 英雄 (BFS)
- 状态压缩DP codeforces 244 Problem C. The Brand New Function 和 codeforces 165 E. Compatible Numbers
- codeforces 16 Problem E fish
- Codeforces Round332 部分题解
- CodeForces 603A_Alternative Thinking (DP)
- CodeForces 602B_Approximating a Constant Range_DP