結果

問題 No.129 お年玉(2)
ユーザー purupuru
提出日時 2016-04-02 17:46:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 395 ms / 5,000 ms
コード長 2,436 bytes
コンパイル時間 1,873 ms
コンパイル使用メモリ 150,760 KB
実行使用メモリ 394,228 KB
最終ジャッジ日時 2023-08-18 17:38:09
合計ジャッジ時間 11,892 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
22,396 KB
testcase_01 AC 395 ms
394,228 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 163 ms
162,168 KB
testcase_06 AC 255 ms
256,792 KB
testcase_07 AC 313 ms
314,556 KB
testcase_08 AC 215 ms
214,524 KB
testcase_09 AC 290 ms
290,052 KB
testcase_10 AC 324 ms
326,036 KB
testcase_11 AC 205 ms
205,548 KB
testcase_12 AC 271 ms
268,568 KB
testcase_13 AC 283 ms
280,996 KB
testcase_14 AC 273 ms
271,620 KB
testcase_15 AC 225 ms
223,340 KB
testcase_16 AC 254 ms
253,776 KB
testcase_17 AC 308 ms
308,636 KB
testcase_18 AC 291 ms
290,504 KB
testcase_19 AC 308 ms
310,040 KB
testcase_20 AC 308 ms
307,732 KB
testcase_21 AC 382 ms
384,804 KB
testcase_22 AC 216 ms
216,820 KB
testcase_23 AC 333 ms
336,160 KB
testcase_24 AC 322 ms
322,712 KB
testcase_25 AC 206 ms
207,000 KB
testcase_26 AC 211 ms
211,804 KB
testcase_27 AC 205 ms
205,828 KB
testcase_28 AC 386 ms
388,688 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 5 ms
5,420 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 4 ms
5,444 KB
testcase_36 AC 4 ms
5,500 KB
testcase_37 AC 5 ms
6,280 KB
testcase_38 AC 45 ms
45,040 KB
testcase_39 AC 68 ms
67,684 KB
testcase_40 AC 193 ms
192,008 KB
testcase_41 AC 118 ms
117,236 KB
testcase_42 AC 49 ms
50,532 KB
testcase_43 AC 48 ms
49,848 KB
testcase_44 AC 388 ms
390,996 KB
testcase_45 AC 28 ms
28,652 KB
testcase_46 AC 76 ms
75,728 KB
testcase_47 AC 376 ms
377,508 KB
testcase_48 AC 226 ms
226,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define debug( fmt, ... ) \
        fprintf( stderr, \
                  fmt "\n", \
                  ##__VA_ARGS__ \
        )

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1 << 29;
const double EPS = 1e-10;

double zero(double d) {
    return d < EPS ? 0.0 : d;
}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, a.size()) os << (i ? " " : "") << a[i];
    return os << ']';
}

string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

const int MOD = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
    ll res = 1ll;
    ll x = a;
    while (k != 0) {
        if ((k & 1) == 1)
            res = (res * x) % M;
        x = (x * x) % M;
        k >>= 1;
    }
    return res;
}

struct prepare {
	prepare() {
	    cout.setf(ios::fixed, ios::floatfield);
	    cout.precision(8);
	    ios_base::sync_with_stdio(false);
	}
} _prepare;

int main() {
    ll N;
    int M;
    cin >> N >> M;

    vvi nCm(M+1, vi(M+1, 0));
    nCm[0][0] = 1;
    rep(i, M) {
        rep(j, i+2) {
            if(j == 0)
                nCm[i+1][j] = nCm[i][j];
            else
                nCm[i+1][j] = ((ll)nCm[i][j] + nCm[i][j-1]) % (int)(1e9);
        }
    }

    int rem = (N % (M * 1000)) / 1000;
    cout << nCm[M][rem] << endl;

    
    return 0;
}
0