結果
問題 | No.129 お年玉(2) |
ユーザー |
![]() |
提出日時 | 2017-07-10 00:38:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 318 ms / 5,000 ms |
コード長 | 484 bytes |
コンパイル時間 | 1,310 ms |
コンパイル使用メモリ | 166,344 KB |
実行使用メモリ | 315,904 KB |
最終ジャッジ日時 | 2024-11-28 00:54:50 |
合計ジャッジ時間 | 10,003 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#include <bits/stdc++.h> #define p(s) cout<<(s)<<endl typedef long long ll; using namespace std; const ll mod=1e9; ll comb[10010][5010]; void combinationDP(int n){ for(int i=0; i < n + 1; i++){ for(int j=0; j < i + 1; j++){ if(j==0 || i==j) comb[i][j]=1; else comb[i][j]=comb[i-1][j-1]+comb[i-1][j]; comb[i][j]%=mod; } } } int main(){ ll n,m; cin>>n>>m; ll dist=n/1000/m; ll r=n-dist*1000*m; r/=1000; r=min(r,m-r); combinationDP(m); p(comb[m][r]); return 0; }