結果
問題 | No.137 貯金箱の焦り |
ユーザー |
![]() |
提出日時 | 2017-09-16 03:00:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1,483 ms / 5,000 ms |
コード長 | 949 bytes |
コンパイル時間 | 2,369 ms |
コンパイル使用メモリ | 158,060 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-07 23:02:42 |
合計ジャッジ時間 | 16,226 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) #define all(c) c.begin(),c.end() #define pb push_back #define fs first #define sc second #define show(x) cout << #x << " = " << x << endl #define chmin(x,y) x=min(x,y) #define chmax(x,y) x=max(x,y) using namespace std; template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";} template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;} typedef long long ll; ll mod = 1234567891; int N; ll M; ll a[50]; ll dp[51000]; int main(){ cin>>N>>M; rep(i,N) cin>>a[i]; dp[0] = 1; while(M){ rep(i,N){ for(int x = 50000;x>=a[i];x--){ dp[x] += dp[x-a[i]]; dp[x] %= mod; } } rep(x,25001) dp[x] = dp[x*2+M%2]; rep(x,25000) dp[x+25000] = 0; M/=2; } cout<<dp[0]<<endl; }