111052024-07-07 00:14:24probaSzámjegycserepython3Runtime error 85/100319ms7796 KiB
# 50, 00, 25, 75
lista = [int(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    
    if i % 25 == 0:
        print(0)
    
    else:
        s = str(i)
        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
2Accepted115ms4800 KiB
subtask323/23
3Accepted266ms7508 KiB
4Accepted273ms7620 KiB
5Accepted277ms7756 KiB
6Accepted277ms7620 KiB
7Accepted272ms7668 KiB
8Accepted310ms7492 KiB
9Accepted272ms7620 KiB
10Accepted279ms7756 KiB
11Accepted273ms7620 KiB
12Accepted268ms7768 KiB
13Accepted289ms7624 KiB
14Accepted275ms7752 KiB
15Accepted277ms7632 KiB
16Accepted312ms7624 KiB
17Accepted282ms7560 KiB
18Accepted279ms7668 KiB
19Accepted298ms7796 KiB
20Accepted296ms7752 KiB
21Accepted291ms7624 KiB
22Accepted273ms7628 KiB
23Accepted272ms7624 KiB
subtask441/41
24Accepted17ms3044 KiB
25Accepted18ms3320 KiB
26Accepted17ms3044 KiB
27Accepted18ms3044 KiB
28Accepted18ms2944 KiB
29Accepted17ms3108 KiB
30Accepted17ms3064 KiB
31Accepted18ms2940 KiB
32Accepted18ms3088 KiB
33Accepted17ms3192 KiB
34Accepted17ms2992 KiB
35Accepted17ms3048 KiB
36Accepted19ms3172 KiB
37Accepted41ms3432 KiB
38Accepted17ms3044 KiB
39Accepted17ms3044 KiB
40Accepted17ms2916 KiB
41Accepted17ms3064 KiB
42Accepted19ms3180 KiB
43Accepted20ms3100 KiB
44Accepted20ms3100 KiB
45Accepted19ms3192 KiB
46Accepted18ms3044 KiB
47Accepted20ms3320 KiB
subtask50/15
48Accepted59ms3576 KiB
49Runtime error17ms3300 KiB
50Accepted319ms7588 KiB
51Runtime error17ms3044 KiB
52Accepted103ms4700 KiB
53Runtime error17ms3044 KiB
54Accepted56ms3704 KiB
55Accepted52ms4196 KiB
56Accepted261ms7640 KiB
57Runtime error18ms3320 KiB
58Runtime error17ms3320 KiB
59Runtime error17ms3320 KiB
60Accepted56ms3684 KiB
61Accepted56ms3684 KiB
62Accepted57ms3704 KiB
63Accepted56ms3704 KiB
64Accepted259ms7660 KiB
65Accepted256ms7624 KiB
66Accepted256ms7772 KiB