Rudro_Debnath

Untitled

Nov 2nd, 2021
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. //#include <ext/pb_ds/assoc_container.hpp>
  3. //#include <ext/pb_ds/tree_policy.hpp>
  4. using namespace std;
  5. //using namespace __gnu_pbds;
  6.  
  7. #define mxx 1e18
  8. #define mnn -1e18
  9. //#define int long long
  10. #define Y() cout<< "YES" <<endl
  11. #define N() cout << "NO"<<endl
  12. #define endl "\n"
  13. #define Ceil(x,y) ((x+y-1)/y)
  14. #define sz(s) (int)s.size()
  15. #define angle(x) double(x * acos(-1) / 180.0)
  16. #define max_3(a,b,c) max(a, max(b,c))
  17. #define min_3(a,b,c) min(a, min(b,c))
  18. #define gcd(a,b) __gcd(a,b)
  19. #define lcm(a,b) (a*b)/gcd(a,b)
  20. #define ll long long
  21. #define PI acos(-1)
  22. #define mem(a,v) memset(a,v,sizeof(a))
  23. #define SORT(v) sort(v.begin(),v.end())
  24. #define REV(v) reverse(v.begin(),v.end())
  25. #define B begin()
  26. #define E end()
  27. #define V vector
  28. #define F first
  29. #define S second
  30. #define PSB push_back
  31. #define MP make_pair
  32. #define flash cout.flush()
  33. #define InTheNameOfGod ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
  34.  
  35. //template <typename T>
  36. //using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
  37. //ordered_set<ll> s;
  38. //*s.find_by_order(x) //val at x index in sorted order.
  39. //s.order_of_key(x); //index of x or if not find x , it show index no in sort array.
  40.  
  41.  
  42. constexpr ll MOD = 998244353;
  43. constexpr ll mod = 1e9 + 7;
  44. const double eps = 1e-7;
  45. int dx[] = {0,0,1,-1};
  46. int dy[] = {1,-1,0,0};
  47. /*-----*/
  48. #define bug1(a) cerr<<a<<endl;
  49. #define bug2(a,b) cerr<<a<<" "<<b<<endl;
  50. #define bug3(a,b,c) cerr<<a<<" "<<b<<" "<<c<<endl;
  51. /*----*/
  52. const ll N=2e6+5;
  53. //vector<ll> adj[N];
  54. ll power(ll n,ll p){if(p==0) return 1;if(p==1)return n;if(p%2)return power(n,p-1)*n;else{ll x=power(n,p/2);return x*x;}}
  55. ll modpow(ll a,ll b,ll m){ll ans=1;while(b){if(b&1)ans=(ans*a)%m;b/=2;a=(a*a)%m;}return ans;}
  56. ll nsum(ll num){return (num*(num+1))/2;}
  57. //void edge (ll u,ll v) {adj[u].PSB(v) ;adj[v].PSB(u);}
  58. /*------------------START---------------------*/
  59. //memset(dp,0x3f,sizeof dp); //3d_dp
  60. void init_code(){
  61. #ifndef ONLINE_JUDGE
  62. InTheNameOfGod
  63. freopen("input.txt","r",stdin);
  64. freopen("output.txt","w",stdout);
  65. #endif
  66. }
  67.  
  68. ll c;
  69. ll dp[105][N];
  70. /*-----*/
  71. void solve(){
  72. ll n,x;
  73. string s;
  74. cin>>n>>x;
  75. V<ll> a(n);
  76. for(ll i=0;i<n;i++) cin>>a[i];
  77.  
  78. dp[0][0]=1;
  79.  
  80. for(ll i=1;i<=n;i++){
  81. for(ll j=0;j<=x;j++){
  82. dp[i][j]=dp[i-1][j];
  83. ll baki= j-a[i-1];
  84. if(baki>=0){
  85. dp[i][j] = (dp[i][j] + dp[i][baki]) % mod;
  86. }
  87. }
  88. }
  89.  
  90. cout<<dp[n][x]<<endl;
  91.  
  92.  
  93.  
  94. //cout << fixed << setprecision(10);
  95. }
  96. /*-----*/
  97. //signed main(){
  98. int main(){
  99. //init_code();
  100. ll Test=1;
  101. //cin>>Test;
  102. while(Test--){
  103. solve();
  104. }
  105. return 0;
  106. }
  107.  
Advertisement
Add Comment
Please, Sign In to add comment