Submission #1798164


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
const int INF = 1 << 29;
const ll LINF = 1l << 61;
const ld PI = abs(acos(-1));
#define pq priotity_queue
#define mp make_pair
#define P pair
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rrep(i, a, b) for (ll i = a; i >= b; i--)
#define cbuf(buf, init) memset(buf, init, sizeof(buf))
#define modp(x, y) (((y) + (x) % (y)) % (y))
#define divd(x, y) (static_cast<double>(x) / static_cast<double>(y))

const ll MOD = 1'000'000'007;

ll K, N;
ll S[200000];

int main()
{
    //
    cin >> N >> K;
    S[0] = 1;
    rep(i, 0, N)
    {
        S[i + 1] = modp(S[i] * 2, MOD);
        ll j = i - K;
        if (j == -2)
            S[i + 1] -= modp(1, MOD);
        else if (j >= 0)
            S[i + 1] -= modp(S[j], MOD);
        S[i + 1] = modp(S[i + 1], MOD);
    }
    cout << S[N - 1] - S[N - 2] << endl;
}

Submission Info

Submission Time
Task F - 準急
User u_anqou
Language C++14 (GCC 5.4.1)
Score 0
Code Size 951 Byte
Status RE
Exec Time 102 ms
Memory 1792 KB

Judge Result

Set Name All
Score / Max Score 0 / 4
Status
AC × 2
RE × 5
Set Name Test Cases
All 00, 01, 02, 03, 04, 90, 91
Case Name Status Exec Time Memory
00 RE 102 ms 1792 KB
01 RE 100 ms 1792 KB
02 RE 101 ms 1792 KB
03 RE 101 ms 1792 KB
04 RE 101 ms 1792 KB
90 AC 1 ms 256 KB
91 AC 1 ms 256 KB