結果
問題 | No.129 お年玉(2) |
ユーザー |
|
提出日時 | 2016-05-04 21:56:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,149 ms / 5,000 ms |
コード長 | 613 bytes |
コンパイル時間 | 703 ms |
コンパイル使用メモリ | 75,224 KB |
実行使用メモリ | 394,880 KB |
最終ジャッジ日時 | 2024-11-28 00:32:29 |
合計ジャッジ時間 | 28,365 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#include <iostream> #include <cmath> #include <vector> using ll = long long int; std::vector<std::vector<int>> memo(10000, std::vector<int>(10000, -1)); ll Combination(ll n, ll r, ll mod){ if(memo[n-1][r]!=-1) return memo[n-1][r]; if(r==0 || n==r){ memo[n-1][r] = 1; return 1; } memo[n-1][r] = (Combination(n-1, r-1, mod) + Combination(n-1, r, mod))%mod; return memo[n-1][r]; } int main(){ std::ios::sync_with_stdio(false); std::cin.tie(0); ll n, m; std::cin >> n >> m; std::cout << Combination(m, (n/1000)%m, 1000000000) << "\n"; return 0; }