1 solutions

  • 2
    @ 2024-3-10 16:27:32
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        string a;
        cin>>a;
        int t=0;
        int c=1;
        int n=a.size();
        for(int i=0;i<n-1;i++)
        {
            if(a[i]>='0'&&a[i]<='9')
            {
                t=t+(a[i]-'0')*c; //累加 
                c++;//增加乘 
            }   
        } 
        int q=t%11;//计算余数 
        if(q==10&&a[n-1]=='X'||q==a[n-1]-'0') cout<<"Right";   //正确匹配 
        else
        {
            if(q==10)
            {
                a[n-1]='X';//最后余数10为x 
            }
            else
            {
                a[n-1]=q+'0'; //更改成正确的数字 
            }
            cout<<a;
        }
        return 0;
    }
    
    • 1

    Information

    ID
    102
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    5
    Tags
    (None)
    # Submissions
    126
    Accepted
    21
    Uploaded By