111062024-07-07 00:48:16probaSzámjegycserepython3Runtime error 85/100818ms3476 KiB
import sys

# uncomment the two following lines if you want to read/write from files
# sys.stdin = open('input.txt')
# sys.stdout = open('output.txt', 'w')

T = int(input().strip())
for test in range(1, T+1):
    N = input().strip()
    
    ans = 0
    
#-----------------------------------    
    # INSERT YOUR CODE HERE
    i = int(N)
    
    # osztható 25-tel    
    if i % 25 == 0:
        ans = 0
    
    else:
        s = str(i)
        m = 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':
                m = 1
            else:
                m = 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':
                m = 1
            else:
                if m == 0:
                    m = 2
                
            
        # ha van benne 2 nulla
        if s.count('0')>1:
            if s[-2:].count('0')==1:
                m = 1
            else:
                if m == 0:
                    m = 2
                
            
        if m == 0:
            ans = -1
        else:
            ans = m
    
   
    
    
#-----------------------------------    
    print(ans)

sys.stdout.close()


SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted17ms3044 KiB
subtask221/21
2Accepted237ms3216 KiB
subtask323/23
3Accepted712ms3360 KiB
4Accepted740ms3364 KiB
5Accepted748ms3344 KiB
6Accepted745ms3300 KiB
7Accepted716ms3428 KiB
8Accepted771ms3264 KiB
9Accepted717ms3348 KiB
10Accepted723ms3344 KiB
11Accepted704ms3396 KiB
12Accepted713ms3420 KiB
13Accepted818ms3416 KiB
14Accepted717ms3396 KiB
15Accepted694ms3476 KiB
16Accepted757ms3300 KiB
17Accepted731ms3300 KiB
18Accepted774ms3448 KiB
19Accepted736ms3180 KiB
20Accepted749ms3336 KiB
21Accepted758ms3248 KiB
22Accepted751ms3300 KiB
23Accepted617ms3448 KiB
subtask441/41
24Accepted17ms3108 KiB
25Accepted18ms3076 KiB
26Accepted18ms3304 KiB
27Accepted18ms3172 KiB
28Accepted18ms2960 KiB
29Accepted17ms3172 KiB
30Accepted17ms3100 KiB
31Accepted18ms3180 KiB
32Accepted17ms3044 KiB
33Accepted18ms3044 KiB
34Accepted18ms3044 KiB
35Accepted18ms3172 KiB
36Accepted24ms2916 KiB
37Accepted76ms3044 KiB
38Accepted18ms3064 KiB
39Accepted18ms3044 KiB
40Accepted17ms2976 KiB
41Accepted18ms3044 KiB
42Accepted24ms3016 KiB
43Accepted24ms2972 KiB
44Accepted23ms3064 KiB
45Accepted24ms3044 KiB
46Accepted17ms3064 KiB
47Accepted24ms3044 KiB
subtask50/15
48Accepted63ms3044 KiB
49Runtime error18ms3300 KiB
50Accepted730ms3344 KiB
51Runtime error17ms3236 KiB
52Accepted192ms3172 KiB
53Runtime error18ms3044 KiB
54Accepted61ms3088 KiB
55Accepted98ms3192 KiB
56Accepted675ms3240 KiB
57Runtime error18ms3364 KiB
58Runtime error17ms3300 KiB
59Runtime error18ms3228 KiB
60Accepted59ms3044 KiB
61Accepted59ms3064 KiB
62Accepted61ms3188 KiB
63Accepted61ms3172 KiB
64Accepted727ms3272 KiB
65Accepted697ms3436 KiB
66Accepted691ms3428 KiB