| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:HELP HELP新手,一直WA了15次,能用的数据都测试过了,还是WAIn Reply To:HELP HELP新手,一直WA了15次,能用的数据都测试过了,还是WA Posted by:fbixiaozc at 2007-07-28 19:38:25 > #include <iostream>//简单,未完2845
> using namespace std;
> const int max = 10000;
> int main()
> {
> char x[max]={0},y[max]={0};
> int ans[max]={0};
> int m;
> cin>>m;
> for (int k=0; k<m; k++)
> {
> cin>>x>>y;
> int temp=0,l=max-1;
> for (int i=strlen(x)-1,j=strlen(y)-1; i>=0&&j>=0; i--,j--)
> {
> if (x[i] == '1' && y[j] == '1')
> {
> ans[l--] = temp;
> temp = 1;
> }
> if (x[i] == '1' && y[j] == '0' || x[i] == '0' && y[j] == '1')
> {
> if (temp == 1) ans[l--] = 0;
> else
> {
> ans[l--] = 1;
> temp=0;
> }
> }
> if (x[i] == '0' && y[j] == '0')
> {
> ans[l--] = temp;
> temp =0;
> }
> }
> if (i >= 0 )
> {
> while (i >= 0)
> {
> if (x[i] == '0')
> {
> ans[l--] = temp;
> temp = 0;
> }
> else
> {
> if (temp == 1) ans[l--] =0 ;
> else
> {
> ans[l--] = x[i]-'0';
> }
> }
> i--;
> }
> }
> else
> {
> while (j >=0)
> {
> if (x[j] == '0')
> {
> ans[l--] = temp;
> temp = 0;
> }
> else
> {
> if (temp == 1) ans[l--] =0 ;
> else
> {
> ans[l--] = y[j]-'0';
> }
> }
> j--;
> }
> }
> cout<<k+1<<' ';
> bool tip=false;
> if (temp == 1)
> {
> cout<<'1';
> tip = true;
> }
>
> for (int q=l+1; q<max; q++)
> {
> if (ans[q] == 1) tip = true;
> if (tip)
> cout<<ans[q];
> }
> if (!tip) cout<<0;
> cout<<endl;
> }
> return 0;
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator