-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy pathsolution.py
More file actions
28 lines (22 loc) · 739 Bytes
/
solution.py
File metadata and controls
28 lines (22 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python
import sys
# driver function
if __name__ == '__main__':
# input number of test cases
T = int(sys.stdin.readline())
for _ in range(T):
# input the number of digits in the number to create
N = int(sys.stdin.readline())
# Print the decent number for the given length, or -1
# if a decent number of that length cannot be formed
if N < 3:
print(-1)
else:
k = N - (N % 3)
if k < N:
while k > 0 and (N - k) % 5 > 0:
k -= 3
if (N - k) % 5 == 0:
print(('5' * k) + ('3' * (N - k)))
else:
print(-1)