CSES - Aalto Competitive Programming 2024 - wk3 - Homework - Results
Submission details
Task:Dice Combinations
Sender:minghao
Submission time:2024-09-18 15:47:38 +0300
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

Output limit exceeded in compilation

Code

#include<iostream>
#include<cstdio>
#include<algorithm>
typedef long long LL;

const int N=1000006, M=1e9+7;
int f[N] = {0, 1, 2, 4, 8, 16, 32}, sum[N];

inline int Add(const int& a, const int& b)
{
    return (a+b)%M;
} //add big num with mod

void Test()
{
    freopen("temp\\in.txt", "r", stdin);
}
int main()
{
    // Test();
    int n;
    scanf("%d", &n);

    for(int i=1; i<=6; i++)
        sum[i] = Add(sum[i-1], f[i]);

    for(int i=7; i<=n; i++)
    {
        f[i] = sum[i-1] - sum[i-7];
        if(f[i] < 0) f[i] += M;
        sum[i] = Add(sum[i-1], f[i]);
    }

    printf("%d", f[n]);

    return 0;
}