gdfz02sjy @ 2024-04-10 15:15:41
#include<bits/stdc++.h>
using namespace std;
char a[13];
long long c,d,e=1;
int main(){
cin>>a;
for(int i=0;i<12;i++){
if(a[i]!='-'){
c+=(a[i]-'0')*e;
e++;
}
}
c=c%11;
if(c==10){
if(a[12]=='X'){
cout<<"right";
return 0;
}
else a[12]=c+'0';
}
else{
if(a[12]==c+'0'){
cout<<"right";
return 0;
}
else{
if(c==10)a[12]='X';
else a[12]=c+'0';
}
}
for(int i=0;i<13;i++)cout<<a[i];
return 0;
}
样例能过,自己测试也能过,洛谷过不了
by 红黑树 @ 2024-04-10 15:18:52
Right 的 R 要大写
by gdfz02sjy @ 2024-04-10 16:43:14
@红黑树 试了,还是一样
by gdfz02sjy @ 2024-04-10 16:43:28
40tps
by turing_IK @ 2024-05-05 22:03:42
@gdfz02sjy ```
using namespace std; int main() { char s[14],c; cin>>s; int h=0,k=0; for(int i=0;i<11;i++) { if(s[i]!='-') { k++; h+=k*(s[i]-'0'); } } h%=11; if(h==10) c='X'; else c=h+'0'; if(c==s[12]) cout<<"Right"<<endl; else { s[12]=c; cout<<s; } return 0; }
by turing_IK @ 2024-05-05 22:04:19
@gdfz02sjy
#include<bits/stdc++.h>
using namespace std;
int main()
{
char s[14],c;
cin>>s;
int h=0,k=0;
for(int i=0;i<11;i++)
{
if(s[i]!='-')
{
k++;
h+=k*(s[i]-'0');
}
}
h%=11;
if(h==10) c='X';
else c=h+'0';
if(c==s[12]) cout<<"Right"<<endl;
else
{
s[12]=c;
cout<<s;
}
return 0;
}
by gdfz02sjy @ 2024-05-08 14:57:42
@tlsonghangtong 谢谢,已关注
by gdfz02sjy @ 2024-05-08 14:58:12
@tlsonghangtong 不过咋错的啊?没看懂