-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1593B.cpp
More file actions
51 lines (43 loc) · 1.06 KB
/
Copy path1593B.cpp
File metadata and controls
51 lines (43 loc) · 1.06 KB
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
51
// Created on 09-Mar-24
//done on oct18,25
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
int main() {
int t;
cin >> t;
while (t--) {
string s;
cin >> s;
int cnt1 = 0, cnt2 = 0;
bool ffound = false, zfound = false;
for (int i = s.size() - 1; i >= 0; i--) {
if (ffound) {
if (((s[i] == '2') || (s[i] == '7'))) {
break;
}
}
if (s[i] == '5' && !ffound) {
ffound = true;
continue;
}
cnt1++;
}
for (int i = s.size() - 1; i >= 0; i--) {
if (zfound) {
if (((s[i] == '0') || (s[i] == '5'))) {
break;
}
}
if (s[i] == '0' && !zfound) {
zfound = true;
continue;
}
cnt2++;
}
cout << (cnt1 < cnt2 ? cnt1 : cnt2) << endl;
}
return 0;
}