| Task: | Dice Combinations |
| Sender: | aalto25b_001 |
| Submission time: | 2025-09-13 17:09:38 +0300 |
| Language: | Python3 (PyPy3) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.04 s | details |
| #2 | ACCEPTED | 0.04 s | details |
| #3 | ACCEPTED | 0.04 s | details |
| #4 | ACCEPTED | 0.04 s | details |
| #5 | ACCEPTED | 0.04 s | details |
| #6 | WRONG ANSWER | 0.04 s | details |
| #7 | WRONG ANSWER | 0.04 s | details |
| #8 | WRONG ANSWER | 0.04 s | details |
| #9 | WRONG ANSWER | 0.04 s | details |
| #10 | WRONG ANSWER | 0.04 s | details |
| #11 | WRONG ANSWER | 0.04 s | details |
| #12 | WRONG ANSWER | 0.06 s | details |
| #13 | WRONG ANSWER | 0.13 s | details |
| #14 | WRONG ANSWER | 0.38 s | details |
| #15 | WRONG ANSWER | 0.55 s | details |
| #16 | WRONG ANSWER | 0.55 s | details |
| #17 | WRONG ANSWER | 0.55 s | details |
| #18 | WRONG ANSWER | 0.07 s | details |
| #19 | WRONG ANSWER | 0.56 s | details |
| #20 | WRONG ANSWER | 0.04 s | details |
Code
coins = [1, 2, 3, 4, 5, 6]
value = []
first = []
count = []
# Break the problem into smaller problems (via momoization) and then find the solution.
def solve(x):
if x < 0: return float("inf")
if (x==0): return 0
if value[x] != -1: return value[x]
best = float("inf")
for coin in coins:
val = solve(x-coin)
if (val != float("inf")): val += 1 # The plus one basically coint for the amount of coins
best = min(best, val)
if x-coin >= 0: first[x] = coin # This gives you the first coin for each sum of money
value[x] = best
return best
def getCoins(x):
global first, value
for i in range(1, x):
value[i] = float("inf")
for c in coins:
if i-c >=0 and value[i-c] + 1 < value[i]:
value[i] = value[i-c] + 1
first[i] = c
# Counts the amount of solutions, everytime you can add a coin, you can add one to the amount of the previous count
def CountSolutions(i):
for x in range(1, i + 1):
for c in coins:
if (x-c >= 0):
count[x] += count[x-c]
count[x] %= (10^9 + 7)
# This is basically a memory that stores a set of values that have been solved to then easily reuse them later when looking for all solutions
def BuildMemoization(x):
global value, first, count
value = [-1 for _ in range(x + 1)]
first = [-1 for _ in range(x + 1)]
count = [0 for _ in range(x + 1)]
value[0] = 0
first[0] = 0
count[0] = 1
for i in range(1, x): solve(i)
def amountOfSolutions(x):
BuildMemoization(x)
CountSolutions(x)
print(count[x])
amountOfSolutions(int(input()))Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 1 |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 2 |
| correct output |
|---|
| 2 |
| user output |
|---|
| 2 |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 3 |
| correct output |
|---|
| 4 |
| user output |
|---|
| 4 |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 4 |
| correct output |
|---|
| 8 |
| user output |
|---|
| 8 |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 5 |
| correct output |
|---|
| 16 |
| user output |
|---|
| 16 |
Test 6
Verdict: WRONG ANSWER
| input |
|---|
| 6 |
| correct output |
|---|
| 32 |
| user output |
|---|
| 6 |
Test 7
Verdict: WRONG ANSWER
| input |
|---|
| 7 |
| correct output |
|---|
| 63 |
| user output |
|---|
| 11 |
Test 8
Verdict: WRONG ANSWER
| input |
|---|
| 8 |
| correct output |
|---|
| 125 |
| user output |
|---|
| 21 |
Test 9
Verdict: WRONG ANSWER
| input |
|---|
| 9 |
| correct output |
|---|
| 248 |
| user output |
|---|
| 14 |
Test 10
Verdict: WRONG ANSWER
| input |
|---|
| 10 |
| correct output |
|---|
| 492 |
| user output |
|---|
| 24 |
Test 11
Verdict: WRONG ANSWER
| input |
|---|
| 50 |
| correct output |
|---|
| 660641036 |
| user output |
|---|
| 7 |
Test 12
Verdict: WRONG ANSWER
| input |
|---|
| 1000 |
| correct output |
|---|
| 937196411 |
| user output |
|---|
| 2 |
Test 13
Verdict: WRONG ANSWER
| input |
|---|
| 123456 |
| correct output |
|---|
| 113810539 |
| user output |
|---|
| 14 |
Test 14
Verdict: WRONG ANSWER
| input |
|---|
| 654321 |
| correct output |
|---|
| 615247550 |
| user output |
|---|
| 24 |
Test 15
Verdict: WRONG ANSWER
| input |
|---|
| 999998 |
| correct output |
|---|
| 39372206 |
| user output |
|---|
| 2 |
Test 16
Verdict: WRONG ANSWER
| input |
|---|
| 999999 |
| correct output |
|---|
| 511319454 |
| user output |
|---|
| 11 |
Test 17
Verdict: WRONG ANSWER
| input |
|---|
| 1000000 |
| correct output |
|---|
| 874273980 |
| user output |
|---|
| 3 |
Test 18
Verdict: WRONG ANSWER
| input |
|---|
| 1001 |
| correct output |
|---|
| 94201505 |
| user output |
|---|
| 17 |
Test 19
Verdict: WRONG ANSWER
| input |
|---|
| 999997 |
| correct output |
|---|
| 74225807 |
| user output |
|---|
| 16 |
Test 20
Verdict: WRONG ANSWER
| input |
|---|
| 40 |
| correct output |
|---|
| 567401756 |
| user output |
|---|
| 14 |
