fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. int main() {
  5. ios::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7. int t;
  8. cin >> t;
  9. while (t--) {
  10. ll n, res = 0;
  11. cin >> n;
  12. while (n > 2) {
  13. ll m1 = n / 3;
  14. ll m2 = m1;
  15. ll m3 = n - m1 - m2;
  16. res += m1;
  17. n = m3;
  18. }
  19. cout << res << "\n";
  20. }
  21. }
  22.  
Success #stdin #stdout 0.01s 5324KB
stdin
3
8
4
3
stdout
3
1
1