andy605 @ 2023-10-30 20:47:09
#include <bits/stdc++.h>
using namespace std;
int sum=0,a,b,c,d;
char d2;
int digit(int x){
int r=0;
while(x>0){
x/=10;
r++;
}
return r;
}
int main(){
scanf("%d-%d-%d-%c",&a,&b,&c,&d2);
switch(d2){
case '0':d=0;break;
case '1':d=1;break;
case '2':d=2;break;
case '3':d=3;break;
case '4':d=4;break;
case '5':d=5;break;
case '6':d=6;break;
case '7':d=7;break;
case '8':d=8;break;
case '9':d=9;break;
case 'X':d=10;break;
}
sum+=a;
int s=b,n=4;
for(int i=1;i<=3;i++){
sum+=(s%10)*n;
s/=10;
n--;
}
s=c;
n=9;
for(int i=1;i<=5;i++){
sum+=(s%10)*n;
s/=10;
n--;
}
sum%=11;
if(sum==d) cout<<"Right\n";
else{
cout<<a<<"-";
for(int i=1;i<=3-digit(b);i++) cout<<0;
cout<<b<<"-";
for(int i=1;i<=5-digit(c);i++) cout<<0;
cout<<c<<"-";
if(d==10){
cout<<"X\n";
}
else{
cout<<sum<<endl;
}
}
return 0;
}
在dev上样例全通过了,自己发现的问题也都解决了, 可在洛谷上还是个50(半AC)!! 望大佬进行debug!!
不知道是不是代码太长了
by Pitiless_boy @ 2023-10-30 21:02:06
@andy605 题目理解有误
by Pitiless_boy @ 2023-10-30 21:03:16
首位数字乘以 1 加上次位数字乘以 2w4td ……以此类推,用所得的结果
by Pitiless_boy @ 2023-10-30 21:03:41
乘以2
by andy605 @ 2023-10-30 21:11:08
麻烦大佬解释得更详细,谢谢!
by Pitiless_boy @ 2023-10-30 21:23:14
@andy605 就是以:0-670-82162-4 为例,识别码的方法是 (0 1 + 6 2 + 7 3 + 0 4 + 8 5 + 2 6 + 1 7 + 6 8 + 2 * 9) % 11
by Pitiless_boy @ 2023-10-30 21:26:07
@andy605 还有记得按回复
按钮at,不然看不到你有没有回复
by andy605 @ 2023-10-30 21:30:29
@Pitiless_boy 感谢大佬,等会儿我再试一下
by Pitiless_boy @ 2023-10-30 21:31:31
@andy605 好的