111112024-07-07 01:05:46probaSzámjegycserepython3Wrong answer 0/100842ms3812 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
    try:
        i = int(N)
        if i % 25 == 0:
            ans = 0
        # osztható 25-tel    
        
        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 = print(m)
        print(ans)
    except:
        print(-1)
  
    
    
#-----------------------------------    
    

sys.stdout.close()


SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer17ms3048 KiB
subtask20/21
2Wrong answer261ms3300 KiB
subtask30/23
3Wrong answer754ms3544 KiB
4Wrong answer792ms3600 KiB
5Wrong answer800ms3600 KiB
6Wrong answer762ms3592 KiB
7Wrong answer718ms3556 KiB
8Wrong answer783ms3684 KiB
9Wrong answer712ms3684 KiB
10Wrong answer800ms3600 KiB
11Wrong answer731ms3556 KiB
12Wrong answer726ms3684 KiB
13Wrong answer813ms3812 KiB
14Wrong answer787ms3704 KiB
15Wrong answer732ms3556 KiB
16Wrong answer842ms3684 KiB
17Wrong answer800ms3600 KiB
18Wrong answer781ms3556 KiB
19Wrong answer774ms3684 KiB
20Wrong answer791ms3684 KiB
21Wrong answer814ms3592 KiB
22Wrong answer791ms3556 KiB
23Wrong answer629ms3556 KiB
subtask40/41
24Accepted17ms3084 KiB
25Accepted17ms3120 KiB
26Accepted18ms3328 KiB
27Accepted17ms3080 KiB
28Accepted18ms3044 KiB
29Accepted18ms3108 KiB
30Accepted17ms3044 KiB
31Accepted17ms3048 KiB
32Accepted17ms2992 KiB
33Wrong answer17ms3044 KiB
34Accepted17ms2996 KiB
35Accepted18ms3192 KiB
36Accepted24ms3048 KiB
37Accepted76ms3192 KiB
38Accepted19ms3064 KiB
39Accepted19ms3064 KiB
40Accepted18ms3016 KiB
41Accepted18ms3044 KiB
42Accepted25ms2916 KiB
43Accepted25ms3044 KiB
44Accepted25ms3044 KiB
45Accepted24ms2972 KiB
46Wrong answer18ms3044 KiB
47Wrong answer25ms3048 KiB
subtask50/15
48Wrong answer64ms3068 KiB
49Wrong answer19ms3604 KiB
50Wrong answer810ms3724 KiB
51Wrong answer41ms3220 KiB
52Wrong answer204ms3320 KiB
53Accepted19ms3172 KiB
54Accepted59ms3136 KiB
55Accepted101ms3172 KiB
56Accepted685ms3304 KiB
57Wrong answer20ms3604 KiB
58Accepted19ms3604 KiB
59Accepted19ms3604 KiB
60Accepted61ms3192 KiB
61Accepted61ms3044 KiB
62Accepted61ms3172 KiB
63Accepted61ms3172 KiB
64Accepted720ms3416 KiB
65Accepted685ms3556 KiB
66Accepted709ms3432 KiB