110982024-07-06 23:00:03probaSzámjegycserepython3Runtime error 0/10018ms3320 KiB
# 50, 00, 25, 75
lista = [int(input()) for i in range(int(input()))]
#lista = [157, 1001, 152, 7500, 7005, 2253, 52, 22, 10011, 55, 505]

for i in lista:
    # osztható 25-tel    
    if i % 25 == 0:
        print(0)
    
    else:
        s = str(i)
        m1, m2, m3 = 0, 0, 0
       
        # van benne 5-ös továbbá 2 vagy 7-es
        if '5' in s and ('2' in s or '7' in s):
            if s[-1]=='5' or (s[-2:]=='57' or s[-2:]=='52') or s[-2]=='7' or s[-2]='2':
                m1 = 1
            else:
                m1 = 2
                
            
        # van benne 5-ös és 0
        if '0' in s and '5' in s:
            if (s[-1] == '5' and s[-2]=='0') or s[-1]=='0' or s[-2]='5':
                m2 = 1
            else:
                m2 = 2
                
            
        # ha van benne 2 nulla
        if s.count('0')>1:
            if s[-1]=='0' or s[-2]=='0':
                m3 = 1
            else:
                m3 = 2
                
            
        if m1+m2+m3 == 0:
            print(-1)
        else:
            x = [m1, m2, m3]
            while 0 in x:
                x.remove(0)
            print(min(x))
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Runtime error17ms3044 KiB
subtask20/21
2Runtime error17ms3044 KiB
subtask30/23
3Runtime error17ms3044 KiB
4Runtime error17ms3068 KiB
5Runtime error17ms3064 KiB
6Runtime error17ms2844 KiB
7Runtime error17ms3044 KiB
8Runtime error17ms3044 KiB
9Runtime error17ms2952 KiB
10Runtime error17ms3056 KiB
11Runtime error17ms3044 KiB
12Runtime error17ms2972 KiB
13Runtime error17ms3044 KiB
14Runtime error17ms3192 KiB
15Runtime error17ms3044 KiB
16Runtime error17ms3048 KiB
17Runtime error17ms3044 KiB
18Runtime error17ms3192 KiB
19Runtime error17ms2972 KiB
20Runtime error17ms2888 KiB
21Runtime error17ms2944 KiB
22Runtime error17ms3172 KiB
23Runtime error17ms2936 KiB
subtask40/41
24Runtime error18ms3044 KiB
25Runtime error17ms2988 KiB
26Runtime error18ms2900 KiB
27Runtime error17ms3088 KiB
28Runtime error17ms3088 KiB
29Runtime error17ms3044 KiB
30Runtime error17ms2880 KiB
31Runtime error17ms3048 KiB
32Runtime error17ms2904 KiB
33Runtime error17ms2976 KiB
34Runtime error17ms3088 KiB
35Runtime error17ms3172 KiB
36Runtime error17ms2860 KiB
37Runtime error17ms2944 KiB
38Runtime error17ms3228 KiB
39Runtime error17ms3064 KiB
40Runtime error18ms2960 KiB
41Runtime error17ms3044 KiB
42Runtime error17ms3040 KiB
43Runtime error17ms3172 KiB
44Runtime error18ms2916 KiB
45Runtime error17ms2916 KiB
46Runtime error17ms3228 KiB
47Runtime error17ms3044 KiB
subtask50/15
48Runtime error18ms2896 KiB
49Runtime error17ms3080 KiB
50Runtime error18ms2916 KiB
51Runtime error17ms2952 KiB
52Runtime error17ms2992 KiB
53Runtime error17ms3044 KiB
54Runtime error17ms3088 KiB
55Runtime error17ms3184 KiB
56Runtime error18ms3320 KiB
57Runtime error18ms2900 KiB
58Runtime error17ms3064 KiB
59Runtime error17ms2928 KiB
60Runtime error17ms2972 KiB
61Runtime error17ms2876 KiB
62Runtime error17ms3064 KiB
63Runtime error17ms2972 KiB
64Runtime error17ms2972 KiB
65Runtime error17ms3044 KiB
66Runtime error17ms2936 KiB