fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define Samurai ios_base::sync_with_stdio(false), cout.tie(NULL), cin.tie(NULL);
  4. #define ll long long
  5. #define pb push_back
  6. #define pu push
  7. #define el '\n'
  8. #define f0() for(int i=0; i<n; i++)
  9. #define f1() for(int i=1; i<=n; i++)
  10. const double PI = acos(-1.0);
  11. const ll mod = 1e9+7, N = 2e5 + 5, OO = 0x3f3f3f3f;
  12. int dx[] = { 0, 0, 1, -1, 1, 1, -1, -1 };
  13. int dy[] = { -1, 1, 0, 0, -1, 1, 1, -1 };
  14.  
  15. void solve(){
  16. int n,a,b,c; cin >> n >> a >> b >> c;
  17. ll d = n/(a+b+c);
  18. d *=3;
  19. n%=(a+b+c);
  20. if(n>0) n-=a, d++;
  21. if(n>0) n-=b, d++;
  22. if(n>0) n-=c, d++;
  23. cout << d << el;
  24. }
  25.  
  26. int main(){ Samurai
  27.  
  28. #ifndef ONLINE_JUDGE
  29. freopen("input.txt", "r", stdin);
  30. freopen("output.txt", "w", stdout);
  31. #endif
  32. int _t = 1;
  33. cin >> _t;
  34. for (int i = 1; i <= _t; i++)
  35. {
  36. solve();
  37. }
  38. return 0;
  39. }
  40.  
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
3