80分qj
查看原帖
80分qj
764672
ZJLmath楼主2022/9/10 17:31
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int n[114514]; 
char d[11454];
int main(){
	cin>>d;
	int l=0,x=0;
	int bz=0;
	for(int i=0;i<strlen(d);i++){
		if(d[i]=='-'){
			x++;
			if(x==3){
				bz=d[i+1]-'0';break;
			}
			continue;
		}
		n[l++]=d[i]-'0';
	}
	unsigned long long int cnt=0;
	for(int i=0;i<l;i++){
		cnt+=n[i]*(i+1);
	}
	cnt%=11;
	if(cnt!=bz){
		for(int i=0;i<strlen(d)-1;i++){
			cout<<d[i];
		}
		if(cnt==10)cout<<"X";
		else cout<<cnt;
	}
	else{
		cout<<"Right";
	}
    return 0;
}

2022/9/10 17:31
加载中...