-
Notifications
You must be signed in to change notification settings - Fork 0
/
1031.cpp
50 lines (44 loc) · 814 Bytes
/
1031.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
int n;
cin>>n;
int weight[17]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
char zm[11]={'1','0','X','9','8','7','6','5','4','3','2'};
vector<string> vec;
vector<string> res;
for(int i=0;i<n;i++)
{
string tmp;
cin>>tmp;
vec.push_back(tmp);
}
for(int i=0;i<n;i++)
{
int tmp=0;
int j=0;
for(j;j<17;j++)
{
if(vec[i][j]>='0'&&vec[i][j]<='9')
tmp=tmp+(vec[i][j]-'0')*weight[j];
else
break;
}
tmp%=11;
if(zm[tmp]!=vec[i][17]||j!=17)
res.push_back(vec[i]);
}
if(res.size()==0)
cout<<"All passed"<<endl;
else
for(int i=0;i<res.size();i++)
{
cout<<res[i]<<endl;
}
return 0;
}