CSES - Aalto Competitive Programming 2024 - wk12 - Wed - Results
Submission details
Task:Dice Summation
Sender:arnxxau
Submission time:2024-11-27 16:42:41 +0200
Language:C++ (C++20)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'void dice(int)':
input/code.cpp:19:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
   19 |     return dp[n];
      |            ~~~~^

Code

#include <bits/stdc++.h>
using namespace std;

void dice(int n) {
    int dp[n + 1];

    dp[0] = 1;

    for (int i = 1; i <= n; i++) {
        dp[i] = 0;

        for (int j = 1; j <= 6; j++) {
            if (i - j >= 0) {
                dp[i] = dp[i] + dp[i - j];
            }
        }
    }

    return dp[n];
}

int main() {
    int n;
    cin >> n;

    dice(n);
}