https://www.acwing.com/problem/content/435/
1 #include<iostream> 2 using namespace std; 3 int main(void){ 4 string s; 5 cin>>s; 6 int res=0; 7 for(int i=0,j=1;i<s.length()-1;i++){ 8 if(s[i]>='0'&&s[i]<='9') 9 res+=j * (s[i]-'0'), j++; 10 } 11 res %= 11; 12 char c='X'; 13 if(res<10) c=char(res+'0'); 14 15 if(s.back()==c) puts("Right"); 16 else{ 17 s.back()=c; 18 cout<<s; 19 } 20 return 0; 21 }