結果

問題 No.129 お年玉(2)
ユーザー firiexpfiriexp
提出日時 2019-08-19 22:36:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 149 ms / 5,000 ms
コード長 1,224 bytes
コンパイル時間 762 ms
コンパイル使用メモリ 100,236 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-27 15:43:19
合計ジャッジ時間 3,952 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,812 KB
testcase_01 AC 149 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 50 ms
6,940 KB
testcase_06 AC 40 ms
6,940 KB
testcase_07 AC 74 ms
6,944 KB
testcase_08 AC 71 ms
6,944 KB
testcase_09 AC 35 ms
6,944 KB
testcase_10 AC 81 ms
6,940 KB
testcase_11 AC 44 ms
6,944 KB
testcase_12 AC 7 ms
6,940 KB
testcase_13 AC 6 ms
6,944 KB
testcase_14 AC 43 ms
6,940 KB
testcase_15 AC 37 ms
6,944 KB
testcase_16 AC 53 ms
6,940 KB
testcase_17 AC 33 ms
6,940 KB
testcase_18 AC 75 ms
6,940 KB
testcase_19 AC 109 ms
6,940 KB
testcase_20 AC 60 ms
6,940 KB
testcase_21 AC 36 ms
6,940 KB
testcase_22 AC 49 ms
6,944 KB
testcase_23 AC 79 ms
6,940 KB
testcase_24 AC 112 ms
6,944 KB
testcase_25 AC 40 ms
6,940 KB
testcase_26 AC 56 ms
6,940 KB
testcase_27 AC 55 ms
6,940 KB
testcase_28 AC 62 ms
6,940 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 1 ms
6,944 KB
testcase_32 AC 2 ms
6,944 KB
testcase_33 AC 1 ms
6,940 KB
testcase_34 AC 2 ms
6,940 KB
testcase_35 AC 1 ms
6,944 KB
testcase_36 AC 2 ms
6,944 KB
testcase_37 AC 2 ms
6,940 KB
testcase_38 AC 8 ms
6,940 KB
testcase_39 AC 9 ms
6,944 KB
testcase_40 AC 21 ms
6,940 KB
testcase_41 AC 27 ms
6,940 KB
testcase_42 AC 12 ms
6,940 KB
testcase_43 AC 4 ms
6,940 KB
testcase_44 AC 117 ms
6,940 KB
testcase_45 AC 8 ms
6,940 KB
testcase_46 AC 5 ms
6,940 KB
testcase_47 AC 110 ms
6,944 KB
testcase_48 AC 73 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <limits>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000000;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }
int main() {
    ll n, m;
    cin >> n >> m;
    n /= 1000;
    n %= m;
    auto dp = make_v(2, n+1, 0);
    dp[0][0] = 1;
    for (int i = 1; i <= m; ++i) {
        int now = i&1, prv = now^1;
        fill(dp[now].begin(),dp[now].end(), 0);
        dp[now][0] = 1;
        for (int j = 1; j <= n; ++j) {
            (dp[now][j] += dp[prv][j-1] + dp[prv][j]) %= MOD;
        }
    }
    cout << dp[m%2][n] << "\n";
    return 0;
}

0