111022024-07-06 23:16:56probaSzámjegycserepython3Runtime error 85/100388ms7792 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, 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[-2:] == '05' 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
1Accepted17ms3044 KiB
subtask221/21
2Accepted141ms4948 KiB
subtask323/23
3Accepted305ms7620 KiB
4Accepted314ms7620 KiB
5Accepted321ms7664 KiB
6Accepted308ms7684 KiB
7Accepted305ms7684 KiB
8Accepted388ms7656 KiB
9Accepted312ms7792 KiB
10Accepted324ms7768 KiB
11Accepted307ms7620 KiB
12Accepted312ms7620 KiB
13Accepted347ms7624 KiB
14Accepted323ms7628 KiB
15Accepted307ms7688 KiB
16Accepted381ms7624 KiB
17Accepted324ms7756 KiB
18Accepted324ms7624 KiB
19Accepted351ms7624 KiB
20Accepted345ms7624 KiB
21Accepted328ms7708 KiB
22Accepted314ms7756 KiB
23Accepted314ms7772 KiB
subtask441/41
24Accepted18ms3192 KiB
25Accepted18ms3044 KiB
26Accepted17ms3044 KiB
27Accepted18ms3044 KiB
28Accepted18ms3096 KiB
29Accepted17ms3216 KiB
30Accepted18ms3180 KiB
31Accepted18ms3172 KiB
32Accepted18ms3108 KiB
33Accepted18ms3224 KiB
34Accepted18ms3172 KiB
35Accepted17ms3044 KiB
36Accepted20ms3172 KiB
37Accepted41ms3304 KiB
38Accepted17ms3044 KiB
39Accepted17ms3064 KiB
40Accepted18ms3192 KiB
41Accepted17ms2904 KiB
42Accepted20ms3248 KiB
43Accepted21ms3188 KiB
44Accepted20ms3100 KiB
45Accepted19ms3172 KiB
46Accepted17ms3044 KiB
47Accepted20ms3120 KiB
subtask50/15
48Accepted59ms3668 KiB
49Runtime error18ms3300 KiB
50Accepted386ms7528 KiB
51Runtime error18ms3192 KiB
52Accepted114ms4800 KiB
53Runtime error17ms3088 KiB
54Accepted56ms3628 KiB
55Accepted54ms4196 KiB
56Accepted275ms7540 KiB
57Runtime error18ms3320 KiB
58Runtime error17ms3304 KiB
59Runtime error18ms3188 KiB
60Accepted56ms3684 KiB
61Accepted57ms3832 KiB
62Accepted57ms3688 KiB
63Accepted57ms3556 KiB
64Accepted273ms7632 KiB
65Accepted273ms7632 KiB
66Accepted273ms7764 KiB