結果

問題 No.129 お年玉(2)
ユーザー playrollerplayroller
提出日時 2019-01-13 19:17:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 191 ms / 5,000 ms
コード長 1,011 bytes
コンパイル時間 1,365 ms
コンパイル使用メモリ 168,748 KB
実行使用メモリ 199,132 KB
最終ジャッジ日時 2023-08-18 18:14:13
合計ジャッジ時間 6,828 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
12,764 KB
testcase_01 AC 178 ms
199,132 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 74 ms
82,724 KB
testcase_06 AC 117 ms
129,948 KB
testcase_07 AC 142 ms
159,024 KB
testcase_08 AC 97 ms
108,840 KB
testcase_09 AC 129 ms
146,436 KB
testcase_10 AC 147 ms
164,636 KB
testcase_11 AC 95 ms
104,448 KB
testcase_12 AC 124 ms
136,024 KB
testcase_13 AC 128 ms
142,208 KB
testcase_14 AC 121 ms
137,452 KB
testcase_15 AC 103 ms
113,280 KB
testcase_16 AC 114 ms
128,732 KB
testcase_17 AC 138 ms
155,888 KB
testcase_18 AC 131 ms
146,912 KB
testcase_19 AC 143 ms
156,644 KB
testcase_20 AC 140 ms
155,544 KB
testcase_21 AC 172 ms
194,376 KB
testcase_22 AC 97 ms
109,916 KB
testcase_23 AC 145 ms
169,540 KB
testcase_24 AC 142 ms
162,984 KB
testcase_25 AC 95 ms
105,408 KB
testcase_26 AC 96 ms
107,620 KB
testcase_27 AC 92 ms
104,476 KB
testcase_28 AC 191 ms
196,040 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 3 ms
4,452 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 3 ms
4,452 KB
testcase_37 AC 3 ms
4,624 KB
testcase_38 AC 20 ms
23,936 KB
testcase_39 AC 31 ms
35,504 KB
testcase_40 AC 86 ms
97,568 KB
testcase_41 AC 57 ms
60,024 KB
testcase_42 AC 22 ms
26,832 KB
testcase_43 AC 21 ms
26,424 KB
testcase_44 AC 171 ms
197,144 KB
testcase_45 AC 12 ms
16,028 KB
testcase_46 AC 34 ms
39,488 KB
testcase_47 AC 168 ms
190,412 KB
testcase_48 AC 103 ms
114,940 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