結果
問題 | No.129 お年玉(2) |
ユーザー |
![]() |
提出日時 | 2015-06-16 22:05:32 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 271 ms / 5,000 ms |
コード長 | 801 bytes |
コンパイル時間 | 711 ms |
コンパイル使用メモリ | 76,264 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-27 23:49:31 |
合計ジャッジ時間 | 5,188 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#include <iostream>#include <algorithm>#include <vector>#include <string>#include <cmath>#include <iomanip>#include <map>using namespace std;typedef long long LL;const LL MOD=1000000000;LL mod_comb(LL n, LL m){vector<LL> prev(m+1);vector<LL> next(m+1);prev[0] = 1;for(int i = 0; i < n; i++){for(int j = 0; j <= m; j++){next[j] += prev[j];next[j] %= MOD;}for(int j = 0; j < m; j++){next[j+1] += prev[j];next[j+1] %= MOD;}next.swap(prev);for(int i = 0; i < next.size(); i++){next[i] = 0;}}return prev[m];}int main(){LL N, M;cin >> N >> M;LL cnt = (N/1000) % M;cout << mod_comb(M, cnt) << endl;return 0;}