結果
問題 | No.129 お年玉(2) |
ユーザー |
![]() |
提出日時 | 2020-04-07 22:34:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 460 ms / 5,000 ms |
コード長 | 938 bytes |
コンパイル時間 | 2,895 ms |
コンパイル使用メモリ | 198,536 KB |
最終ジャッジ日時 | 2025-01-09 14:55:29 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#include<bits/stdc++.h> #define ALL(v) std::begin(v),std::end(v) using lint=long long; using lubl=long double; lint mod=1'000'000'000; struct mint{ lint value; mint()=default; mint(lint x):value(x){} }; std::ostream&operator<<(std::ostream&os,mint x){return os<<x.value;} mint operator+(mint x,mint y){lint z=x.value+y.value;if(mod<=z)z-=mod;return z;} mint&operator+=(mint&x,mint y){return x=x+y;} int main(){ std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false); std::cout.setf(std::ios_base::fixed);std::cout.precision(15); lint a,b;std::cin>>a>>b; a/=1'000; a%=b; std::vector<std::vector<mint>>binom(b+1); binom.at(0)={1}; for(lint i=0;i<b;i++){ binom.at(i+1).resize(i+2); for(lint j=0;j<=i;j++){ mint x=binom.at(i).at(j); binom.at(i+1).at(j)+=x; binom.at(i+1).at(j+1)+=x; } } std::cout<<binom.at(b).at(a)<<'\n'; }