結果
問題 | No.129 お年玉(2) |
ユーザー |
|
提出日時 | 2018-08-27 14:43:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 475 ms / 5,000 ms |
コード長 | 794 bytes |
コンパイル時間 | 720 ms |
コンパイル使用メモリ | 72,944 KB |
実行使用メモリ | 394,496 KB |
最終ジャッジ日時 | 2024-11-28 01:11:10 |
合計ジャッジ時間 | 12,061 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#include<iostream> #include<vector> using namespace std; typedef long long ll; int mod = 1e9; struct Combination{ int n; vector<vector<int>> dp; Combination(int i){ n = i; dp = vector<vector<int>>(n+1, vector<int>(n+1, 0)); constructTriangle(); } void constructTriangle(){ dp[0][0] = 1; for(int i = 1; i <= n; i++){ dp[i][0] = dp[i-1][0]; for(int j = 1; j <= i; j++){ dp[i][j] = (dp[i-1][j] + dp[i-1][j-1]) % mod; } } } // return aCb int getCombination(int a, int b){ return dp[a][b]; } }; int main(){ ll n; int m; cin >> n >> m; n /= 1000; Combination c(m); cout << c.getCombination(m, n%m) << endl; return 0; }