97032024-03-02 13:07:30szellandKiváló Számokpython3Accepted 100/100930ms47640 KiB
def sum1(string):
    n = 0
    
    for i in string:
        n += int(i)

    return n

def to_str(inp):
    r = ''
    for i in inp:
        r += i
    return r

input = int(input())

num1 = '1' * input

def solve(num) -> str:
    if num != '5' * input:
        if sum1(num) % 3 == 0:
            return num
        else:
            num = list(num)
            num[0] = '5'
            num = sorted(num)
            num = to_str(num)
            return solve(num)
    else:
        return -1

print(solve(num1))
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted18ms11404 KiB
subtask233/33
2Accepted17ms11688 KiB
3Accepted17ms12116 KiB
4Accepted17ms11928 KiB
5Accepted18ms12392 KiB
6Accepted17ms12668 KiB
7Accepted17ms12480 KiB
8Accepted17ms12728 KiB
subtask333/33
9Accepted71ms13620 KiB
10Accepted479ms29768 KiB
11Accepted150ms15192 KiB
12Accepted301ms28944 KiB
13Accepted310ms29428 KiB
14Accepted177ms22276 KiB
15Accepted126ms17184 KiB
16Accepted68ms14416 KiB
17Accepted101ms15364 KiB
18Accepted337ms32244 KiB
19Accepted129ms20452 KiB
20Accepted435ms37704 KiB
subtask434/34
21Accepted930ms47640 KiB
22Accepted187ms20496 KiB
23Accepted584ms46044 KiB
24Accepted237ms18340 KiB
25Accepted186ms17664 KiB
26Accepted104ms16264 KiB
27Accepted778ms42428 KiB
28Accepted671ms38924 KiB
29Accepted89ms18872 KiB
30Accepted358ms33860 KiB
31Accepted375ms33452 KiB
32Accepted26ms15224 KiB
33Accepted35ms15128 KiB