小错不断,简直灾难
// 14'52"
#include <bits/stdc++.h>
using namespace std;
#define int long long
int arr[17] = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
signed main()
{
int n;
cin >> n;
map<int,char> map;
map.insert({0,'1'});
map.insert({1,'0'});
map.insert({2,'X'});
map.insert({3,'9'});
map.insert({4,'8'});
map.insert({5,'7'});
map.insert({6,'6'});
map.insert({7,'5'});
map.insert({8,'4'});
map.insert({9,'3'});
map.insert({10,'2'});
vector<string> res;
for(int i = 1; i <= n; ++ i)
{
string s;
cin >> s;
int flag = false;
int sum = 0;
for(int j = 0; j < s.size() - 1; ++ j)
{
if(s[j] < '0' || s[j] > '9')
{
flag = true;
break;
}
sum += arr[j] * (s[j] - '0');
}
sum %= 11;
if(flag || s[s.size() - 1] != map[sum]) res.push_back(s);
}
if(res.size() == 0) cout << "All passed";
else
{
for(int i = 0; i < res.size(); ++ i)
{
cout << res[i];
if(i != res.size() - 1) cout << endl;
}
}
return 0;
}
标签:map,15,insert,int,res,sum,016,L1,size
From: https://www.cnblogs.com/Frodnx/p/18335554