fork download
  1. /*input
  2. 3 3 3 100
  3. 1 1 1
  4. */
  5. #include <bits/stdc++.h>
  6. #include<stdio.h>
  7. using namespace std;
  8. #define pii pair<long long,long long>
  9. #define F(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
  10. #define RF(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); i--)
  11. #define PI 3.14159265
  12. #define ll long long
  13. #define ff first
  14. #define ss second
  15. #define pb(x) push_back(x)
  16. #define mp(x,y) make_pair(x,y)
  17. #define debug(x) cout << #x << " = " << x << endl
  18. #define INF 1000000009
  19. ll n,m,b,mod,ans;
  20. ll arr[1000];
  21. ll f(ll lines,ll progid,ll bugs)
  22. {
  23. cout<<progid<<" "<<lines<<" "<<ans<<endl;
  24. if(lines>m || bugs>b || progid>n)
  25. return 0;
  26. if(lines==m && bugs<=b)
  27. return 1;
  28. ans=0;
  29. F(i,0,m)
  30. {
  31. if(lines+i<=m && bugs+i*arr[progid]<=b && progid+1<=n)
  32. ans = ans + f(lines+i,progid+1,bugs+i*arr[progid]);
  33. }
  34. return ans;
  35. }
  36. int main()
  37. {
  38. std::ios::sync_with_stdio(false);
  39. cin>>n>>m>>b>>mod;
  40. F(i,1,n)
  41. cin>>arr[i];
  42. cout<<f(0,1,0)<<endl;
  43. return 0;
  44. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
1 0 0
0