fork download
  1. #include<bits/stdc++.h>
  2. #define M1 1000000007
  3. #define M2 998244353
  4. #define ll long long int
  5. #define N (int)1e5+3
  6. #define test(t) while(t--)
  7. #define PI acos(-1.0)
  8. #define pll pair<ll,ll>
  9. #define pii pair<int,int>
  10. #define mii map<int,int>
  11. #define rep(i,a,b) for(ll i=a;i<b;i++)
  12. #define repp(i,b,a) for(ll i=b-1;i>=a;i--)
  13. #define clr(ar, val) memset(ar, val, sizeof(ar))
  14. #define F first
  15. #define S second
  16. #define PB push_back
  17. #define mp make_pair
  18. #define lb lower_bound
  19. #define ub upper_bound
  20. #define V(a) vector<a>
  21. #define M(a,b) map<a,b>
  22. #define endl '\n'
  23. #define all(x) begin(x),end(x)
  24. #define allr(x) rbegin(x),rend(x)
  25. #define pr(a) cout<<a<<endl;
  26. #define pr2(a,b) cout<<a<<" "<<b<<"\n"
  27. const int inf = 0x3f3f3f3f;
  28. const ll INF = 0x3f3f3f3f3f3f3f3f;
  29. const int dx[4] = { 0, -1, 0, 1 };
  30. const int dy[4] = { -1, 0, 1, 0 };
  31. using namespace std;
  32.  
  33. ll CalculateMex(set<ll> Set){
  34. ll Mex = 0;
  35. while(Set.find(Mex)!=Set.end()){
  36. Mex++;
  37. }
  38. return Mex;
  39. }
  40.  
  41. inline void INP()
  42. {
  43. #ifndef ONLINE_JUDGE
  44. freopen("input.txt","r",stdin);
  45. freopen("output.txt","w",stdout);
  46. #endif
  47. }
  48. map<ll,ll> m;
  49. ll solve(ll n)
  50. {
  51. if (n == 0) return 0;
  52. if (n == 2) return 2;
  53. if (n == 3) return 3;
  54. if (n == 4) return 4;
  55. if (m[n] != 0) return m[n];
  56. ll p1 = solve(n/2) + solve(n/3) + solve(n/4);
  57. return m[n] = max(n,p1);
  58. }
  59.  
  60. int32_t main(){
  61. ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  62. int t=1;
  63. // cin>>t;
  64. test(t){
  65. ll n;
  66. cin >> n;
  67. cout << solve(n) << endl;
  68. }
  69. return 0;
  70. }
Success #stdin #stdout 0s 4392KB
stdin
Standard input is empty
stdout
1570514887302607