fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. #define endl "\n"
  4. #define F first
  5. #define S second
  6. #define loop(a,n) for(int i=a; i<=n ; i++)
  7. #define TIME (1.0 * clock() / CLOCKS_PER_SEC)
  8. #define NAME ""
  9. using namespace std;
  10.  
  11. int main(){
  12. ios_base::sync_with_stdio(0);
  13. cin.tie(0);cout.tie(0);
  14. //freopen(NAME".INP","r",stdin);
  15. //freopen(NAME".OUT","w",stdout);
  16. int n,a,b,c;
  17. cin>>n;
  18. if(n<5) cout<<2;
  19. else {
  20. a=2,b=3,c=a;
  21. while(a<=n) {
  22. c=a;
  23. a+=b;
  24. b*=3;
  25.  
  26. }
  27. cout<<c;
  28. }
  29. return 0;
  30. }
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
29525