Advertisement
Saleh127

Light oj(LO) 1232

May 18th, 2021
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10.  
  11. test
  12. {
  13.  
  14. ll n,m,i,j,k,l=100000007;
  15.  
  16. cin>>n>>k;
  17.  
  18. ll c[n+5],dp[k+5];
  19.  
  20. for(i=0;i<n;i++) cin>>c[i];
  21.  
  22.  
  23. memset(dp,0,sizeof dp);
  24. dp[0]=1;
  25.  
  26. for(i=0;i<n;i++)
  27. {
  28. for(j=c[i];j<=k;j++)
  29. {
  30. dp[j]+=(dp[j-c[i]]);
  31. dp[j]%=l;
  32. }
  33. }
  34. cout<<"Case "<<cs<<": "<<dp[k]<<endl;
  35. }
  36.  
  37. return 0;
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement