Monicaca @ 2022-09-19 21:23:10
RE数据:
in:6-670-82162-X
out:Right
明明分支语句也不会算很慢的样子,为什么RE有结果却过不了呢?第一次遇到这种情况虚心求教
num = input()
num1 = num.split('-')
s = num.replace('-', '')
t = 0
n = 0
for i in range(len(s)-1):
n += 1
q = int(s[i])*n
t += q
r = t % 11
if s[-1] == 'X':#原字符串是X
old = 10
if r == old:#算的对
print('Right')
else:
num1[-1] = str(r)
num2 = '-'.join(num1)
print(num2)
else:#原字符串不是X
if r == 10:#新算的是X
new = 'X'
num1[-1] = new
num2 = '-'.join(num1)
print(num2)
else:
if int(s[-1]) == r:
print('Right')
else:
num1[-1] = str(r)
num2 = '-'.join(num1)
print(num2)
by nszcdeqmnjzl @ 2022-10-05 18:02:13
下了数据点in:6-670-82162-X out:Right
by suqiu11 @ 2022-10-18 21:13:18
我也和楼主一个情况,请问您解决了问题了吗
by Zr221010 @ 2022-10-27 22:34:01
俺也一样
by szm2386988211 @ 2022-11-25 17:26:37
@nszcdeqmnjzl out不应该是-4,我也是re
by nszcdeqmnjzl @ 2022-12-02 16:25:49
不会py qwq
#include<iostream>
using namespace std;
char x[114],r;
char e;
int main(){
cin>>x[1];
cin>>e;
cin>>x[2];
cin>>x[3];
cin>>x[4];
cin>>e;
cin>>x[5];
cin>>x[6];
cin>>x[7];
cin>>x[8];
cin>>x[9];
cin>>e;
cin>>r;
int ans=0;
for(int i=1;i<=9;i++){
ans+=(x[i]-'0')*i;
}ans%=11;
if(r=='X') r='0'+10;
if(ans==r-'0'){
cout<<"Right";
return 0;
}
else{
cout<<x[1];
cout<<e;
cout<<x[2];
cout<<x[3];
cout<<x[4];
cout<<e;
cout<<x[5];
cout<<x[6];
cout<<x[7];
cout<<x[8];
cout<<x[9];
cout<<e;
if(ans==10)cout<<'X';
else cout<<ans;
}
return 0;
}
by nszcdeqmnjzl @ 2022-12-06 13:24:15
@szm2386988211 c++彳亍吗 o( ^ 3^)o