CSES - Aalto Competitive Programming 2024 - wk3 - Homework - Results
Submission details
Task:Dice Combinations
Sender:minghao
Submission time:2024-09-16 14:45:02 +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=1e6+5, M=1e9+7;
LL f[N] = {0, 1, 2, 4, 8, 16, 32}, sum[N];

inline LL Add(const LL& a, const LL& 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<=n; i++)
        sum[i] = sum[i-1] + f[i];

    for(int i=7; i<=n; i++)
    {
        f[i] = sum[i-1] - sum[i-7];
        sum[i] = sum[i-1] + f[i];
    }

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

    return 0;
}