| Task: | Alien Invasion II |
| Sender: | lnan95 |
| Submission time: | 2020-09-19 15:26:34 +0300 |
| Language: | Python3 (CPython3) |
| Status: | READY |
| Result: | TIME LIMIT EXCEEDED |
| test | verdict | time | |
|---|---|---|---|
| #1 | TIME LIMIT EXCEEDED | -- | details |
| #2 | TIME LIMIT EXCEEDED | -- | details |
| #3 | TIME LIMIT EXCEEDED | -- | details |
Code
import math
flag = 0
def isPrime(num):
sqr = int(math.sqrt(num))+1
for i in range(2, sqr+1):
if num % i == 0:
return i
return -1
def bfs(num, depth, length):
global flag
if flag==1:
return
if depth == 2:
return
for i in range(1,10):
m = i*int(math.pow(10, length)) + num
r = isPrime(m)
if r != -1 and flag != 1:
flag = 1
print (m)
print (r, int(m/r), sep=" ", end="")
return
for i in range(1,10):
m = i*int(math.pow(10, length)) + num
bfs(m, depth+1, length+1)
if __name__ == "__main__":
n = int(input())
length = 0
r = isPrime(n)
if r != -1:
flag = 1
print (n)
print (r, int(n/r), sep=" ", end="")
n_cp = n
while (n_cp > 0):
n_cp = n_cp // 10
length += 1
bfs(n, 0, length)
Test details
Test 1
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 2368469234876449 |
| correct output |
|---|
| 22368469234876449 3 7456156411625483 |
| user output |
|---|
| (empty) |
Test 2
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 292929292929292929292929292931 |
| correct output |
|---|
| 129292929292929292929292929293... |
| user output |
|---|
| (empty) |
Test 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 292929292929292929292929292979 |
| correct output |
|---|
| 129292929292929292929292929297... |
| user output |
|---|
| (empty) |
