111002024-07-06 23:05:20probaSzámjegycserepython3Runtime error 85/100388ms7808 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
2Accepted141ms4800 KiB
subtask323/23
3Accepted303ms7660 KiB
4Accepted312ms7684 KiB
5Accepted324ms7664 KiB
6Accepted312ms7656 KiB
7Accepted308ms7640 KiB
8Accepted382ms7664 KiB
9Accepted312ms7664 KiB
10Accepted331ms7584 KiB
11Accepted314ms7608 KiB
12Accepted308ms7680 KiB
13Accepted345ms7700 KiB
14Accepted324ms7808 KiB
15Accepted312ms7668 KiB
16Accepted388ms7624 KiB
17Accepted328ms7756 KiB
18Accepted323ms7624 KiB
19Accepted363ms7624 KiB
20Accepted349ms7668 KiB
21Accepted328ms7624 KiB
22Accepted319ms7624 KiB
23Accepted310ms7688 KiB
subtask441/41
24Accepted18ms3044 KiB
25Accepted17ms3080 KiB
26Accepted18ms3044 KiB
27Accepted17ms3044 KiB
28Accepted17ms3044 KiB
29Accepted17ms3188 KiB
30Accepted18ms3044 KiB
31Accepted18ms3044 KiB
32Accepted17ms3048 KiB
33Accepted19ms3112 KiB
34Accepted18ms3044 KiB
35Accepted17ms3044 KiB
36Accepted21ms3172 KiB
37Accepted43ms3428 KiB
38Accepted18ms3116 KiB
39Accepted18ms3180 KiB
40Accepted18ms2908 KiB
41Accepted18ms3044 KiB
42Accepted20ms3060 KiB
43Accepted20ms3320 KiB
44Accepted19ms3172 KiB
45Accepted20ms3228 KiB
46Accepted18ms3192 KiB
47Accepted21ms3172 KiB
subtask50/15
48Accepted59ms3576 KiB
49Runtime error17ms3080 KiB
50Accepted386ms7476 KiB
51Runtime error18ms3336 KiB
52Accepted114ms4676 KiB
53Runtime error17ms3064 KiB
54Accepted57ms3684 KiB
55Accepted56ms4344 KiB
56Accepted275ms7560 KiB
57Runtime error17ms3300 KiB
58Runtime error17ms3444 KiB
59Runtime error17ms3300 KiB
60Accepted57ms3848 KiB
61Accepted57ms3556 KiB
62Accepted57ms3684 KiB
63Accepted57ms3704 KiB
64Accepted270ms7632 KiB
65Accepted270ms7448 KiB
66Accepted273ms7760 KiB