4 条题解

  • 1
    @ 2026-8-20 16:53:01
    #include <string>
    using namespace std;
    int a,b,c[] = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2},sum;
    char d[] = {'1','0','X','9','8','7','6','5','4','3','2'};
    string s;
    bool l;
    int main(){
    	cin >> a;
    	while(a--){
    		cin >> s;
    		l = true;
    		for(int i = 0 ; i < 17 ; i++){
    			if(!isdigit(s[i])){
    				l = false;
    				break;
    			}
    		}
    		if(!l){
    			cout << "False" << endl;
    			continue;
    		}
    		sum = 0;
    		for(int i = 0 ; i < 17 ; i++) sum += (s[i] - '0') * c[i];
    		b = sum % 11;
    		if(s[17] == d[b]) cout << "True" << endl;
    		else cout << "False" << endl;
    	}
    	return 0;
    }
    
    
    
    • 1
      @ 2025-4-18 18:38:36
      #include <iostream>
      #include <string>
      using namespace std;
      int a,b,c[] = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2},sum;
      char d[] = {'1','0','X','9','8','7','6','5','4','3','2'};
      string s;
      bool l;
      int main(){
      	cin >> a;
      	while(a--){
      		cin >> s;
      		l = true;
      		for(int i = 0 ; i < 17 ; i++){
      			if(!isdigit(s[i])){
      				l = false;
      				break;
      			}
      		}
      		if(!l){
      			cout << "False" << endl;
      			continue;
      		}
      		sum = 0;
      		for(int i = 0 ; i < 17 ; i++) sum += (s[i] - '0') * c[i];
      		b = sum % 11;
      		if(s[17] == d[b]) cout << "True" << endl;
      		else cout << "False" << endl;
      	}
      	return 0;
      }
      
      • -2
        @ 2025-4-18 18:22:28

        #include<bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; int a[] = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2}; char b[] = {'1','0','X','9','8','7','6','5','4','3','2'}; int main() { int n,ans =0; string s; cin >> n; getline(cin,s); int len=s.size(); for(int i = 0; i <len-1;i++) { ans +=(s[i]-'0') * a[i]; } ans%= 11; if(b[ans]==s[17]) { cout << "True" <<endl; } else{ cout << "False" << endl; } return 0; } #include<bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; int a[] = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2}; char b[] = {'1','0','X','9','8','7','6','5','4','3','2'}; int main() { int n,ans =0; string s; cin >> n; getline(cin,s); int len=s.size(); for(int i = 0; i <len-1;i++) { ans +=(s[i]-'0') * a[i]; } ans%= 11; if(b[ans]==s[17]) { cout << "True" <<endl; } else{ cout << "False" << endl; } return 0; } 慢慢分行吧

        • -4
          @ 2025-4-18 18:27:53
          #include <iostream>
          #include <string>
          using namespace std;
          int a,b,c[] = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2},sum;
          char d[] = {'1','0','X','9','8','7','6','5','4','3','2'};
          string s;
          bool l;
          int main(){
          	cin >> a;
          	while(a--){
          		cin >> s;
          		l = true;
          		for(int i = 0 ; i < 17 ; i++){
          			if(!isdigit(s[i])){
          				l = false;
          				break;
          			}
          		}
          		if(!l){
          			cout << "True" << endl;
          			continue;
          		}
          		sum = 0;
          		for(int i = 0 ; i < 17 ; i++) sum += (s[i] - '0') * c[i];
          		b = sum % 11;
          		if(s[17] == d[b]) cout << "True"<< endl;
          		else cout <<  "False" << endl;
          	}
          	return 0;
          }
          
          
          
          • 1

          信息

          ID
          1155
          时间
          1000ms
          内存
          256MiB
          难度
          7
          标签
          递交数
          295
          已通过
          65
          上传者