一二三四五 上山打老虎

CCF-CSP-2013-12-2

链接:http://118.190.20.162/view.page?gpid=T4

代码:

#include<bits/stdc++.h>

using namespace std;

int a[]={0,0,2,3,4,6,7,8,9,10};
string str;
int main (){
    cin>>str;
    int num=0;
    for(int i=1;i<=9;i++){
        num+=(i*(int)(str[a[i]]-'0'));
    }
    num%=11;
    if(num==10&&str[12]=='X')
        cout<<"Right";
    else if(num==str[12]-'0')
        cout<<"Right";
    else {
        cout<<str.substr(0,12);
       num==10 ? cout<<"X":cout<<num;
    }
    return 0;
}

posted @ 2021-03-27 19:12  黒川川  阅读(36)  评论(0)    收藏  举报