-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path354.cpp
More file actions
43 lines (41 loc) · 749 Bytes
/
Copy path354.cpp
File metadata and controls
43 lines (41 loc) · 749 Bytes
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
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
cin >> n;
string line;
getline(cin, line);
for (int i=0;i<n;i++) {
getline(cin, line);
bool choose = true;
int sum = 0;
for (int i=(int)line.length()-1;i>=0;i--) {
if (line[i] >= 48 && line[i] <= 57) {
choose = !choose;
if (choose) {
int temp = line[i] - 48;
temp *= 2;
sum += (temp / 10) + (temp % 10);
}
}
}
choose = false;
for (int i=(int)line.length()-1;i>=0;i--) {
if (line[i] >= 48 && line[i] <= 57) {
choose = !choose;
if (choose) {
int temp = line[i] - 48;
sum += temp;
}
}
}
if (sum % 10 == 0) {
cout << "Valid\n";
}
else {
cout << "Invalid\n";
}
}
return 0;
}