fork download
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. // your code goes here
  7. int t;
  8. cin>>t;
  9. while(t--)
  10. {
  11. int n;
  12. cin>>n;
  13. if(n==0||n==1||n==2)
  14. {
  15. cout<<"0"<<endl;
  16.  
  17. }
  18. else
  19. {
  20. if(n%2==0)
  21. {
  22. cout<<(n/2)+1<<endl;
  23.  
  24. }
  25. else if(n%2==1)
  26. {
  27. cout<<floor(n/2)<<endl;
  28. }
  29.  
  30. }
  31. }
  32. return 0;
  33. }
Success #stdin #stdout 0.01s 5312KB
stdin
6
7
1
2
3
2000000000
763243547
stdout
3
0
0
1
1000000001
3.81622e+08