110992024-07-06 23:03:44probaSzámjegycserepython3Runtime error 85/100389ms7832 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[-1] == '5' and s[-2]=='0') 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
2Accepted137ms4772 KiB
subtask323/23
3Accepted298ms7832 KiB
4Accepted310ms7636 KiB
5Accepted319ms7636 KiB
6Accepted314ms7672 KiB
7Accepted310ms7700 KiB
8Accepted388ms7572 KiB
9Accepted310ms7688 KiB
10Accepted328ms7764 KiB
11Accepted312ms7620 KiB
12Accepted307ms7476 KiB
13Accepted342ms7768 KiB
14Accepted328ms7664 KiB
15Accepted312ms7640 KiB
16Accepted382ms7640 KiB
17Accepted326ms7660 KiB
18Accepted333ms7684 KiB
19Accepted349ms7624 KiB
20Accepted347ms7796 KiB
21Accepted326ms7624 KiB
22Accepted314ms7624 KiB
23Accepted312ms7500 KiB
subtask441/41
24Accepted18ms3192 KiB
25Accepted18ms3044 KiB
26Accepted18ms3192 KiB
27Accepted18ms3192 KiB
28Accepted18ms3128 KiB
29Accepted18ms3204 KiB
30Accepted17ms3100 KiB
31Accepted17ms3192 KiB
32Accepted18ms3044 KiB
33Accepted18ms3320 KiB
34Accepted18ms3172 KiB
35Accepted17ms3044 KiB
36Accepted20ms3320 KiB
37Accepted43ms3556 KiB
38Accepted17ms3044 KiB
39Accepted17ms3108 KiB
40Accepted18ms3100 KiB
41Accepted18ms2944 KiB
42Accepted20ms3100 KiB
43Accepted19ms3188 KiB
44Accepted20ms3356 KiB
45Accepted21ms3172 KiB
46Accepted18ms3060 KiB
47Accepted21ms3172 KiB
subtask50/15
48Accepted59ms3684 KiB
49Runtime error17ms3192 KiB
50Accepted389ms7652 KiB
51Runtime error18ms3044 KiB
52Accepted112ms4624 KiB
53Runtime error17ms3044 KiB
54Accepted57ms3616 KiB
55Accepted54ms4256 KiB
56Accepted273ms7672 KiB
57Runtime error17ms3300 KiB
58Runtime error17ms3300 KiB
59Runtime error17ms3172 KiB
60Accepted57ms3684 KiB
61Accepted57ms3684 KiB
62Accepted57ms3684 KiB
63Accepted57ms3684 KiB
64Accepted273ms7628 KiB
65Accepted270ms7776 KiB
66Accepted273ms7628 KiB