2018徐州网络赛I

签到题~

#include <iostream>

using namespace std;

inline int Abs(int x)
{
    return (x>0?x:(-x));
}

int main()
{
    char s[100007];
    char ans[300007];
    char se,c;
    int l,ll,t;
    int T;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d %c",&l,&se);
        ll=l*2;
        getchar();
        for(int i=1;i<=l;i++)
        {
            //cout<<i<<endl;
            scanf("%c",&c);
            t = Abs(se-c);
            if(t<10)
            {
                ans[i*2-1]='0';
                ans[i*2]='0'+t;
            }
            else
            {
                ans[i*2-1]='0'+t/10;
                ans[i*2]='0'+t%10;
            }
        }
        getchar();
        int i=1,tot=ll;
        while(i<=ll&&ans[i]=='0')
        {
            i++;tot--;
        }
        if(tot==0)tot++;
        printf("%d\n",tot);    
    }
    return 0;
}
View Code

猜你喜欢

转载自www.cnblogs.com/LMissher/p/9615321.html