Submission details
Task:Alkuluvut
Sender:pupukani
Submission time:2025-09-28 16:45:31 +0300
Language:Python3 (PyPy3)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.04 s1, 2, 3details
#2--2, 3details
#3--3details

Code

def on_alkuluku(luku):
    if luku == 1:
        return False
    if luku == 2:
        return True
    for i in range(2, luku // 2):
        if luku % i == 0:
            return False
    return True

def tee_alkuluku(luku, numerot):
    if len(luku) > 17:
        return 0
    if len(luku) > 0 and on_alkuluku(int(luku)):
        return luku
    for i in range(0, len(numerot)):
        luku = luku + numerot[i];
        ret = tee_alkuluku(luku, numerot)
        if ret != 0:
            return ret;
        luku = luku[:-1]
    return 0

def main():
    t = int(input())
    tuloste = ""
    for i in range(t):
        k = int(input())
        rivi = input()
        numerot = rivi.split()
        alkuluku = int(tee_alkuluku("", numerot))
        if alkuluku == 0:
            tuloste = tuloste + "NO\n"
        else:
            tuloste = tuloste + "YES\n"
            tuloste = tuloste + str(alkuluku) + "\n";
    print(tuloste)

main()

Test details

Test 1

Group: 1, 2, 3

Verdict:

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:

input
175
1
0
1
1
...

correct output
NO
YES
11
YES
2
...

user output
(empty)

Test 3

Group: 3

Verdict:

input
848
4
0 1 2 3
4
0 1 2 4
...

correct output
YES
10223
YES
4021
YES
...

user output
(empty)