結果

問題 No.129 お年玉(2)
ユーザー playrollerplayroller
提出日時 2019-01-13 19:17:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 208 ms / 5,000 ms
コード長 1,011 bytes
コンパイル時間 2,011 ms
コンパイル使用メモリ 170,000 KB
実行使用メモリ 198,912 KB
最終ジャッジ日時 2024-05-05 23:57:22
合計ジャッジ時間 7,550 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
12,928 KB
testcase_01 AC 208 ms
198,912 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 82 ms
82,944 KB
testcase_06 AC 134 ms
130,176 KB
testcase_07 AC 168 ms
159,104 KB
testcase_08 AC 113 ms
109,056 KB
testcase_09 AC 152 ms
146,688 KB
testcase_10 AC 173 ms
164,864 KB
testcase_11 AC 108 ms
104,704 KB
testcase_12 AC 141 ms
136,192 KB
testcase_13 AC 147 ms
142,464 KB
testcase_14 AC 142 ms
137,600 KB
testcase_15 AC 116 ms
113,536 KB
testcase_16 AC 132 ms
128,896 KB
testcase_17 AC 162 ms
156,160 KB
testcase_18 AC 151 ms
147,200 KB
testcase_19 AC 163 ms
156,928 KB
testcase_20 AC 163 ms
155,776 KB
testcase_21 AC 201 ms
194,304 KB
testcase_22 AC 113 ms
110,208 KB
testcase_23 AC 177 ms
169,856 KB
testcase_24 AC 170 ms
163,200 KB
testcase_25 AC 109 ms
105,216 KB
testcase_26 AC 111 ms
107,776 KB
testcase_27 AC 107 ms
104,576 KB
testcase_28 AC 203 ms
196,224 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 3 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 3 ms
5,376 KB
testcase_36 AC 3 ms
5,376 KB
testcase_37 AC 3 ms
5,376 KB
testcase_38 AC 23 ms
24,064 KB
testcase_39 AC 34 ms
35,712 KB
testcase_40 AC 99 ms
97,792 KB
testcase_41 AC 60 ms
60,288 KB
testcase_42 AC 27 ms
27,136 KB
testcase_43 AC 27 ms
26,624 KB
testcase_44 AC 204 ms
197,376 KB
testcase_45 AC 14 ms
16,000 KB
testcase_46 AC 39 ms
39,552 KB
testcase_47 AC 201 ms
190,464 KB
testcase_48 AC 118 ms
115,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  i64 n;
  int m;
  cin >> n >> m;
  int k = (n / 1000) % m;

  vvt<int> pascal(m + 1);
  pascal[0] = vt<int>(1, 1);
  pascal[1] = vt<int>(2, 1);
  rep(i, 2, m + 1) {
    pascal[i] = vt<int>(i + 1, -1);
    pascal[i][0] = pascal[i][i] = 1;
    rep(j, 1, i + 1) {
      if(pascal[i][j] != -1) break;
      pascal[i][j] = pascal[i][i - j] = (pascal[i - 1][j - 1] + pascal[i - 1][j]) % mod;
    }
  }
  cout << pascal[m][k] << endl;
}
0