fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. long long n,tmp;
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  8. cin>>n;
  9. if(n == 1)
  10. {
  11. cout<<3<<'\n';
  12. }
  13. else if(n == 2)
  14. {
  15. cout<<5<<'\n';
  16. }
  17. else
  18. {
  19. tmp = n/3;
  20. cout<<tmp*4+3+(n%3)<<'\n';
  21. }
  22. }
Success #stdin #stdout 0.01s 5316KB
stdin
3
stdout
7