fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int Max = 2210, Maxp = 5605, MOD = 998244353;
  5. int n, p, c[Max];
  6. ll dp[Max][Maxp];
  7.  
  8. int main(){
  9. freopen("subsubset.inp", "r", stdin);
  10. freopen("subsubset.out", "w", stdout);
  11. cin >> n >> p;
  12. for (int i=1; i<=n; i++) cin >> c[i];
  13. dp[0][0] = 1;
  14. ll ans = 0;
  15. for (int i=1; i<=n; i++) for (int j=0; j<=p; j++) {
  16. dp[i][j] = (dp[i-1][j]+dp[i-1][j-c[i]])%MOD;
  17. ans = (ans+dp[i][j])%MOD;
  18. }
  19.  
  20. cout << ans << endl;
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty