120382024-11-26 12:17:02markmaster78Számjegycserepython3Accepted 100/100337ms10880 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
1Accepted17ms3124 KiB
subtask221/21
2Accepted116ms5832 KiB
subtask323/23
3Accepted287ms10880 KiB
4Accepted298ms10872 KiB
5Accepted291ms10748 KiB
6Accepted287ms10740 KiB
7Accepted291ms10772 KiB
8Accepted321ms10784 KiB
9Accepted289ms10876 KiB
10Accepted296ms10756 KiB
11Accepted289ms10696 KiB
12Accepted296ms10696 KiB
13Accepted305ms10764 KiB
14Accepted296ms10696 KiB
15Accepted287ms10696 KiB
16Accepted321ms10788 KiB
17Accepted289ms10804 KiB
18Accepted293ms10768 KiB
19Accepted316ms10664 KiB
20Accepted314ms10664 KiB
21Accepted293ms10660 KiB
22Accepted298ms10660 KiB
23Accepted289ms10664 KiB
subtask441/41
24Accepted16ms3312 KiB
25Accepted16ms2996 KiB
26Accepted16ms3140 KiB
27Accepted14ms3184 KiB
28Accepted17ms3320 KiB
29Accepted14ms3144 KiB
30Accepted16ms2980 KiB
31Accepted16ms3128 KiB
32Accepted14ms3224 KiB
33Accepted14ms3116 KiB
34Accepted14ms3128 KiB
35Accepted17ms3236 KiB
36Accepted17ms3356 KiB
37Accepted37ms3440 KiB
38Accepted16ms3224 KiB
39Accepted17ms3196 KiB
40Accepted16ms3128 KiB
41Accepted16ms3132 KiB
42Accepted17ms3308 KiB
43Accepted18ms3256 KiB
44Accepted17ms3128 KiB
45Accepted18ms3304 KiB
46Accepted16ms3168 KiB
47Accepted19ms3144 KiB
subtask515/15
48Accepted23ms4260 KiB
49Accepted20ms4288 KiB
50Accepted337ms10748 KiB
51Accepted20ms4112 KiB
52Accepted90ms5688 KiB
53Accepted18ms4036 KiB
54Accepted20ms4164 KiB
55Accepted45ms5080 KiB
56Accepted272ms10688 KiB
57Accepted17ms4212 KiB
58Accepted18ms4352 KiB
59Accepted18ms4276 KiB
60Accepted21ms4288 KiB
61Accepted20ms4300 KiB
62Accepted20ms4292 KiB
63Accepted21ms4152 KiB
64Accepted273ms10820 KiB
65Accepted270ms10688 KiB
66Accepted268ms10692 KiB