Task: | Alkuluvut |
Sender: | tkok |
Submission time: | 2025-09-27 16:07:22 +0300 |
Language: | Python3 (CPython3) |
Status: | READY |
Result: | 17 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 17 |
#2 | RUNTIME ERROR | 0 |
#3 | RUNTIME ERROR | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.02 s | 1, 2, 3 | details |
#2 | RUNTIME ERROR | 0.53 s | 2, 3 | details |
#3 | RUNTIME ERROR | 0.02 s | 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 if k == 2: if nums[0] == 0: if nums == (0, 1): print("YES") print(101) else: print("NO") luku = [0,0] while len(luku) < 14: n = 0 while True: if len(luku) > n: if luku[n] == 0: luku[n] += 1 break else: luku[n] = 0 if n == len(luku): luku = [0, *luku] break n += 1 numero = 0 for v in luku: numero = numero * 10 + nums[v] if alkuluku_testain(numero): print("YES") print(numero) break else: luku = [0, 0, 0] while len(luku) < 14: n = 0 while True: if len(luku) > n: if luku[n] < len(luku) - 1: luku[n] += 1 break else: luku[n] = 0 if n == len(luku): luku = [0, *luku] break n += 1 numero = 0 for v in luku: numero = numero * 10 + nums[v] if alkuluku_testain(numero): print("YES") print(numero) break
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: RUNTIME ERROR
input |
---|
175 1 0 1 1 ... |
correct output |
---|
NO YES 11 YES 2 ... |
user output |
---|
NO YES 11 YES 2 ... |
Error:
Traceback (most recent call last): File "/box/input/code.py", line 80, in <module> numero = numero * 10 + nums[v] IndexError: tuple index out of range
Test 3
Group: 3
Verdict: RUNTIME ERROR
input |
---|
848 4 0 1 2 3 4 0 1 2 4 ... |
correct output |
---|
YES 10223 YES 4021 YES ... |
user output |
---|
YES 1 YES 1 YES ... |
Error:
Traceback (most recent call last): File "/box/input/code.py", line 80, in <module> numero = numero * 10 + nums[v] IndexError: tuple index out of range