UVA - 1588 Kickdown

Kickdown

 UVA - 1588 

题目传送门

解决方法:上板不动,下板向左移;上板不动,下板向右移。

AC代码:

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define inf 0x3f3f3f3f
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define lep(i,l,r) for(int i=l;i>=r;i--)
#define ms(arr) memset(arr,0,sizeof(arr))
//priority_queue ,greater >q;
const int maxn = (int)1e5 + 5;
const ll mod = 1e9+7;
char s1[maxn];
char s2[maxn];
char s3[maxn];
int main() 
{
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    #endif
    //freopen("out.txt", "w", stdout);
    while(scanf("%s",s1)!=EOF)
    {
        scanf("%s",s2);
        int len1=strlen(s1);
        int len2=strlen(s2);
        if(len1=0;i--)
        {
            k1=i;
            id1=s1[k1]-'0';
            id2=s2[k2]-'0';
            while(id1+id2<=3)
            {
                nape1++;
                k1--;
                k2--;
                if(k1==-1||k2==-1)
                {
                    ju1=true;
                    break;
                }
                id1=s1[k1]-'0';
                id2=s2[k2]-'0';
            }
            if(ju1)
                break;
            else
            {
                k2=len2-1;
                nape1=0;
            }
        }
        nape=max(nape,nape1);
        printf("%d\n",len1+len2-nape);
    }
    return 0;
}

 

你可能感兴趣的:(紫书——数组与字符串(习题),模拟,算法竞赛入门经典(紫书))