111122024-07-07 09:40:48probaSzámjegycserepython3Accepted 100/100351ms10948 KiB
# 50, 00, 25, 75
lista = [input() for i in range(int(input()))]
#lista = [157, 1001, 152, 7500, 7005, 200253, 52, 22, 10011, 55, 505]#

for i in lista:
    # osztható 25-tel
    s = str(i)
    if '00' in s[-2:] or '25' in s[-2:] or '50' in s[-2:] or '75' in s[-2:]:
        print(0)
    
    else:
        
        m1 = 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[-2:] == '05' or s[-1]=='0' or s[-2]=='5':
                m1 = 1
            else:
                if m1 == 0:
                    m1 = 2
                
            
        # ha van benne 2 nulla
        if s.count('0')>1:
            if s[-1]=='0' or s[-2]=='0':
                m1 = 1
            else:
                if m1 == 0:
                    m1 = 2
                
            
        if m1 == 0:
            print(-1)
        else:
            print(m1)
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted17ms3044 KiB
subtask221/21
2Accepted127ms5964 KiB
subtask323/23
3Accepted300ms10688 KiB
4Accepted300ms10760 KiB
5Accepted317ms10736 KiB
6Accepted305ms10740 KiB
7Accepted307ms10820 KiB
8Accepted351ms10692 KiB
9Accepted307ms10820 KiB
10Accepted310ms10756 KiB
11Accepted307ms10756 KiB
12Accepted303ms10820 KiB
13Accepted324ms10692 KiB
14Accepted312ms10948 KiB
15Accepted312ms10784 KiB
16Accepted345ms10692 KiB
17Accepted319ms10820 KiB
18Accepted324ms10820 KiB
19Accepted330ms10780 KiB
20Accepted331ms10732 KiB
21Accepted307ms10844 KiB
22Accepted305ms10812 KiB
23Accepted305ms10760 KiB
subtask441/41
24Accepted17ms3044 KiB
25Accepted17ms3192 KiB
26Accepted18ms3304 KiB
27Accepted17ms3044 KiB
28Accepted18ms3192 KiB
29Accepted17ms3064 KiB
30Accepted17ms3192 KiB
31Accepted17ms3172 KiB
32Accepted17ms2972 KiB
33Accepted17ms2984 KiB
34Accepted17ms3064 KiB
35Accepted17ms3192 KiB
36Accepted20ms3320 KiB
37Accepted43ms3348 KiB
38Accepted17ms3064 KiB
39Accepted17ms3068 KiB
40Accepted17ms3064 KiB
41Accepted17ms2992 KiB
42Accepted20ms3204 KiB
43Accepted20ms3216 KiB
44Accepted19ms3172 KiB
45Accepted20ms3140 KiB
46Accepted18ms3064 KiB
47Accepted20ms3192 KiB
subtask515/15
48Accepted26ms4196 KiB
49Accepted21ms4404 KiB
50Accepted347ms10592 KiB
51Accepted24ms4140 KiB
52Accepted97ms5680 KiB
53Accepted21ms4208 KiB
54Accepted23ms4324 KiB
55Accepted48ms4964 KiB
56Accepted280ms10696 KiB
57Accepted19ms4472 KiB
58Accepted20ms4324 KiB
59Accepted19ms4344 KiB
60Accepted24ms4340 KiB
61Accepted23ms4196 KiB
62Accepted24ms4344 KiB
63Accepted24ms4264 KiB
64Accepted277ms10696 KiB
65Accepted282ms10824 KiB
66Accepted291ms10696 KiB