結果
問題 | No.129 お年玉(2) |
ユーザー |
![]() |
提出日時 | 2015-02-09 16:25:20 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 67 ms / 5,000 ms |
コード長 | 657 bytes |
コンパイル時間 | 422 ms |
コンパイル使用メモリ | 56,696 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 23:39:46 |
合計ジャッジ時間 | 3,187 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#include <iostream> #include <algorithm> using namespace std; #define MOD 1000000000 typedef long long LL; int upper[10010]; int lower[10010]; int main(){ LL n,m; cin >> n >> m; LL equal = n/1000/m*1000; //一人がもらえる量 LL rest = n - equal * m; LL rest_maisuu = rest/1000; upper[0] = upper[1] = 1; for(int i=2;i<=m;++i){ for(int j=0;j<=i;++j){ lower[j] = (upper[j-1]+upper[j])%MOD; } for(int j=1;j<=i+1;++j) upper[j] = lower[j]; // for(int j=1;j<=i+1;++j) cout << lower[j] << " "; // cout << endl; } if(rest_maisuu==0) cout << 1 << endl; else cout << lower[rest_maisuu] << endl; return 0; }