| Task: | Alkuluvut |
| Sender: | tkok |
| Submission time: | 2025-09-27 16:12:46 +0300 |
| Language: | Python3 (CPython3) |
| Status: | READY |
| Result: | 17 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 17 |
| #2 | TIME LIMIT EXCEEDED | 0 |
| #3 | TIME LIMIT EXCEEDED | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.02 s | 1, 2, 3 | details |
| #2 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
| #3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
t = int(input())
def alkuluku_testain(n: int) -> bool:
if n & 1 == 0:
return False
v = 3
while v ** 2 <= n:
if n % v == 0:
return False
v += 2
return True
for i in range(t):
k = int(input())
nums = [int(x) for x in input().split()]
nums = sorted(nums)
nums = tuple(nums)
if k == 1:
numero = nums[0]
if numero in {2, 3, 5, 7}:
print("YES")
print(numero)
if numero == 1:
print("YES")
print(11)
if numero in {0, 4, 6, 8, 9}:
print("NO")
continue
if all(x % 2 == 0 for x in nums):
print("NO")
continue
luku = [0, 0, 0]
while len(luku) < 16:
n = 0
while True:
if len(luku) > n:
if luku[n] < len(nums) - 1:
luku[n] += 1
break
else:
luku[n] = 0
if n == len(luku):
luku = [0, *luku]
break
n += 1
if len(set(luku)) < k:
continue
numero = 0
for v in luku:
numero = numero * 10 + nums[v]
if alkuluku_testain(numero):
print("YES")
print(numero)
break
else:
print("NO")Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 10 1 0 1 1 ... |
| correct output |
|---|
| NO YES 11 YES 2 ... |
| user output |
|---|
| NO YES 11 YES 2 ... |
Test 2
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 175 1 0 1 1 ... |
| correct output |
|---|
| NO YES 11 YES 2 ... |
| user output |
|---|
| (empty) |
Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 848 4 0 1 2 3 4 0 1 2 4 ... |
| correct output |
|---|
| YES 10223 YES 4021 YES ... |
| user output |
|---|
| (empty) |
