CSES - Datatähti 2023 alku - Results
Submission details
Task:Kertoma
Sender:jusola
Submission time:2022-10-31 20:18:21 +0200
Language:Python3 (CPython3)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED22
#2ACCEPTED24
#3ACCEPTED54
Test results
testverdicttimegroup
#1ACCEPTED0.02 s1, 2, 3details
#2ACCEPTED0.02 s1, 2, 3details
#3ACCEPTED0.02 s1, 2, 3details
#4ACCEPTED0.02 s1, 2, 3details
#5ACCEPTED0.02 s1, 2, 3details
#6ACCEPTED0.02 s1, 2, 3details
#7ACCEPTED0.02 s2, 3details
#8ACCEPTED0.02 s2, 3details
#9ACCEPTED0.02 s2, 3details
#10ACCEPTED0.02 s2, 3details
#11ACCEPTED0.02 s3details
#12ACCEPTED0.02 s3details
#13ACCEPTED0.02 s3details
#14ACCEPTED0.02 s3details
#15ACCEPTED0.02 s3details
#16ACCEPTED0.02 s3details

Code

import math
input = input().split(" ")


coefstable = {
(3000, 20000): [-2.8890754318020678e-40, 4.1828819430954729e-35,-2.6747741350693512e-30,
  9.9589719215020828e-26,-2.3982999427431329e-21, 3.9308845136812149e-17,
 -4.5118666629747629e-13, 3.7225595542126587e-09,-2.3853857908690323e-05,
  4.0544237854708914e-01, 6.9094877481209195e+01],
(20000, 85000): [-2.1481083076396559e-46, 1.3665144475483009e-40,-3.8689193064020790e-35,
  6.4359566887460784e-30,-6.9995359842553530e-25, 5.2480119916656532e-20,
 -2.7982963374591532e-15, 1.0930625784436208e-10,-3.4038263579480189e-06,
  3.2823593384545641e-01, 2.2231288254255796e+02],
(85000, 470000): [-7.7308938919757422e-53, 2.4873951574235631e-46,-3.5571578782239750e-40,
  2.9843962137632934e-34,-1.6342191707024561e-28, 6.1579909591522356e-23,
 -1.6472209065144264e-17, 3.2239057708316843e-12,-5.0416704617221765e-07,
  2.7439102219670264e-01, 7.5296139272445271e+02],
(470000, 1000000): [ 5.7573092508688498e-57,-3.7060632034359153e-50, 1.0011299760732353e-43,
 -1.3927555341331923e-37, 8.2489430830870810e-32, 4.5075391502645615e-26,
 -1.3654386631285936e-19, 1.3888462452766127e-13,-9.5825172795642546e-08,
  2.3911594159887509e-01, 2.2917012785055294e+03]
}

counts = {}
l = 0

for i, n in enumerate(input):
    n = int(n)
    counts[str(i)] = n
    l += n

# below this is faster and more accurate
if l < 3000:
    n = 0
    while True:
        n += 1
        fact = math.factorial(n)
        s = str(fact)
        valid = True
        for c in counts:
            if not s.count(c) == counts[c]:
                valid = False
                break
        if valid:
            print(n)
            break
else:
    coefs = []

    for k in coefstable:
        if l >= k[0] and l <= k[1]:
            coefs = coefstable[k]
            break

    n = 0
    polfactor = len(coefs) - 1
    for i, v in enumerate(coefs):
        n += v*(l**(polfactor - i))

    n = round(n)

    print(n)

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
0 0 1 0 0 0 0 0 0 0

correct output
2

user output
2

Test 2

Group: 1, 2, 3

Verdict: ACCEPTED

input
0 0 0 0 0 0 1 0 0 0

correct output
3

user output
3

Test 3

Group: 1, 2, 3

Verdict: ACCEPTED

input
0 0 1 0 1 0 0 0 0 0

correct output
4

user output
4

Test 4

Group: 1, 2, 3

Verdict: ACCEPTED

input
2 0 1 1 0 0 1 0 2 0

correct output
10

user output
10

Test 5

Group: 1, 2, 3

Verdict: ACCEPTED

input
9 3 1 1 2 2 3 1 6 1

correct output
27

user output
27

Test 6

Group: 1, 2, 3

Verdict: ACCEPTED

input
10 4 3 4 3 2 2 4 3 7

correct output
36

user output
36

Test 7

Group: 2, 3

Verdict: ACCEPTED

input
71 53 36 30 25 29 42 24 34 29

correct output
199

user output
199

Test 8

Group: 2, 3

Verdict: ACCEPTED

input
71 33 46 38 27 45 36 21 35 35

correct output
205

user output
205

Test 9

Group: 2, 3

Verdict: ACCEPTED

input
93 38 35 26 43 54 38 25 41 34

correct output
222

user output
222

Test 10

Group: 2, 3

Verdict: ACCEPTED

input
100 33 33 45 36 43 38 54 56 36

correct output
242

user output
242

Test 11

Group: 3

Verdict: ACCEPTED

input
3419 1797 1845 1849 1879 1791 ...

correct output
5959

user output
5959

Test 12

Group: 3

Verdict: ACCEPTED

input
4776 2695 2709 2781 2616 2753 ...

correct output
8391

user output
8391

Test 13

Group: 3

Verdict: ACCEPTED

input
20097 12282 12229 12214 12406 ...

correct output
32001

user output
32001

Test 14

Group: 3

Verdict: ACCEPTED

input
47934 29918 29878 29713 29984 ...

correct output
71718

user output
71718

Test 15

Group: 3

Verdict: ACCEPTED

input
84691 54156 54277 54533 54296 ...

correct output
123123

user output
123123

Test 16

Group: 3

Verdict: ACCEPTED

input
99098 63339 63878 64182 63904 ...

correct output
142663

user output
142663