116022024-10-29 23:39:40KezdőSzámjegycserepython3Accepted 100/100564ms3648 KiB
T = int(input())
for i in range(T):
    N = input()
##s = [300,325,50,75,215,6715,540,20040,520,5073,205,2003,157,1001,152,7500,7005,200253,52,22,10011,55,505]
##for x in s:
##    N = str(x)
    v = -1
    nul = N.count('0')
    if len(N) >= 2:
        if N[-2:] in ['00','25', '50', '75']:
            v = 0
        elif N[-2:] in ['52', '05', '57']:
            v = 1
        elif N[-1] == '5' and (('2' in N) or ('7' in N)):
            v = 1
        elif N[-1] == '0' and (('5' in N) or nul >= 2):
            v = 1
        elif N[-2] in '72' and '5' in N:
            v = 1
        elif N[-2] == '5' and '0' in N:
            v = 1
        elif N[-2] == '0' and nul >= 2:
            v = 1
        elif ('5' in N) and (('2' in N) or ('7' in N) or ('0' in N)):
            v = 2
        elif  nul >= 2:
            v = 2
    print(v)
    
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted14ms3112 KiB
subtask221/21
2Accepted180ms3128 KiB
subtask323/23
3Accepted518ms3384 KiB
4Accepted523ms3384 KiB
5Accepted524ms3384 KiB
6Accepted510ms3248 KiB
7Accepted518ms3384 KiB
8Accepted564ms3248 KiB
9Accepted522ms3400 KiB
10Accepted527ms3376 KiB
11Accepted515ms3304 KiB
12Accepted521ms3448 KiB
13Accepted519ms3384 KiB
14Accepted528ms3384 KiB
15Accepted521ms3384 KiB
16Accepted523ms3368 KiB
17Accepted521ms3436 KiB
18Accepted523ms3268 KiB
19Accepted528ms3384 KiB
20Accepted518ms3212 KiB
21Accepted523ms3256 KiB
22Accepted521ms3384 KiB
23Accepted504ms3444 KiB
subtask441/41
24Accepted17ms3124 KiB
25Accepted17ms3144 KiB
26Accepted17ms3120 KiB
27Accepted17ms3132 KiB
28Accepted16ms3168 KiB
29Accepted17ms2988 KiB
30Accepted16ms3128 KiB
31Accepted16ms3096 KiB
32Accepted17ms3128 KiB
33Accepted17ms3140 KiB
34Accepted17ms3120 KiB
35Accepted17ms3128 KiB
36Accepted21ms3172 KiB
37Accepted54ms3212 KiB
38Accepted16ms3032 KiB
39Accepted17ms3036 KiB
40Accepted17ms3172 KiB
41Accepted17ms3132 KiB
42Accepted20ms2960 KiB
43Accepted20ms3128 KiB
44Accepted21ms3076 KiB
45Accepted21ms3128 KiB
46Accepted16ms3000 KiB
47Accepted19ms3128 KiB
subtask515/15
48Accepted25ms3060 KiB
49Accepted19ms3508 KiB
50Accepted509ms3188 KiB
51Accepted19ms3232 KiB
52Accepted120ms3132 KiB
53Accepted17ms3136 KiB
54Accepted23ms3188 KiB
55Accepted70ms3188 KiB
56Accepted521ms3480 KiB
57Accepted20ms3648 KiB
58Accepted17ms3452 KiB
59Accepted18ms3472 KiB
60Accepted21ms3024 KiB
61Accepted24ms3060 KiB
62Accepted23ms3140 KiB
63Accepted24ms3212 KiB
64Accepted564ms3468 KiB
65Accepted523ms3384 KiB
66Accepted501ms3364 KiB