G2A Many GEOs
SHARE
TWEET

Untitled

a guest Apr 5th, 2020 150 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. int ar[105], n, k;
  5. int dp[105][10005];
  6.  
  7. int solve()
  8. {
  9.     for(int i=0; i<n; i++) {
  10.         for(int j=0; j<=k; j++) {
  11.             if(i==0 || j==0) dp[i][j]=1;
  12.             else if(j<ar[i]) dp[i][j]=dp[i-1][j];
  13.             else dp[i][j]=dp[i-1][j]+dp[i][j-ar[i]];
  14.             dp[i][j]=dp[i][j]%100000007;
  15.         }
  16.     }
  17.     return dp[n-1][k];
  18. }
  19.  
  20. main()
  21. {
  22.     int t;
  23.     scanf("%lld", &t);
  24.     for(int j=1; j<=t; j++) {
  25.         scanf("%lld %lld", &n, &k);
  26.         for(int i=0; i<n; i++) scanf("%lld", &ar[i]);
  27.         printf("Case %lld: %lld\n", j, solve());
  28.     }
  29. }
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top