wuliu21 @ 2025-01-11 18:10:29
#include <bits/stdc++.h>
using namespace std;
long long sum;
string s;
int main(){
cin >> s;
for(long long i = 0,j = 1;i < s.size() - 1;i++){
if(s[i] == '-'){
continue;
}
sum += (s[i] - '0') * j++;
}
sum %= 11;
if(sum == s[s.size() - 1] - '0'){
cout << "Right";
}else{
for(long long i = 0;i < s.size() - 1;i++){
cout << s[i];
}
if(sum == 10){
cout << "X";
}else{
cout << sum;
}
}
return 0;
}
by An15163220501 @ 2025-01-11 18:34:50
@wuliu21
# include <bits/stdc++.h>
using namespace std;
int cnt;
int main()
{
string t;
cin >> t;
string s;
s[0] = t[0],s[1] = t[2],s[2] = t[3],s[3] = t[4],s[4] = t[6],s[5] = t[7],s[6] = t[8],s[7] = t[9],s[8] = t[10];
int a[10];
for (int i = 0;i < 9;i++)
a[i + 1] = s[i] - '0';
for (int i = 1;i <= 9;i++)
cnt += a[i] * i;
if (cnt % 11 != 10 && cnt % 11 == t[12] - '0' || t[12] == 'X' && cnt % 11 == 10)
cout << "Right" << endl;
else
{
for (int i = 0;i < 12;i++)
cout << t[i];
if (cnt % 11 != 10)
cout << cnt % 11 << endl;
else
cout << 'X' << endl;
}
return 0;
}
我最开始也栽这俩测试点上了,改了接近两小时很长时间
by wuliu21 @ 2025-01-11 19:12:57
谢谢