| ||||||||||
| 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 | |||||||||
晕 还是WA...莫非我理解错了?#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
string a, b;
int cal()
{
int i, j, k;
i = 0;
while(i<b.length())
{
k = 0;
while(k<a.length())
{
j = k+i;
if(!(b[j] == '2' && a[k]=='2') ||j>=b.length())
k++;
else break;
}
if(k==a.length())
{
int ans = i+a.length();
if(ans < b.length()) ans = b.length();
return ans;
}
i++;
}
return a.length()+b.length();
}
int main()
{
while(cin >> b >> a)
{
int x1 = cal();
reverse(a.begin(), a.end());
reverse(b.begin(), b.end());
int x2 = cal();
if(x2>x1) x2 = x1;
cout << x2 << 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