fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int a[100], ok, n ;
  4. void ktao (){
  5. for (int i = 1; i <= n ;i++){
  6. a[i] = 0;
  7. }
  8. }
  9. void sinh(){
  10. int i = n;
  11. while (i > 0 && a[i] == 1){
  12. a[i] = 0;
  13. --i;
  14. }
  15. if (i == 0){
  16. ok = 0;
  17. }
  18. else {
  19. a[i] = 1;
  20. }
  21. }
  22. int main (){
  23. int t; cin >> t;
  24. while (t--){
  25. int q , b;
  26. cin >> n >> q >> b;
  27. int h[n];
  28. for (int &x : h) cin >> x;
  29. int cnt = 0;
  30. ok = 1;
  31.  
  32. ktao ();
  33. while (ok){
  34. int sum = 0;
  35. for (int i = 1; i <= n ;i++){
  36. if (a[i] == 1) sum += h[i -1];
  37. }
  38. if (sum >= q && sum <= b){
  39. cnt++;
  40. }
  41. sinh();
  42. }
  43. cout << cnt << endl;
  44. }
  45. }
  46.  
Success #stdin #stdout 0.01s 5272KB
stdin
Standard input is empty
stdout
Standard output is empty