fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void divMax(int n){
  5. int f[n+1];
  6. f[0] = 0;
  7. f[1] = 1;
  8. f[2] = 2;
  9. f[3] = 3;
  10. for(int i=4;i<=n;i++){
  11. f[i] = max(i,(f[i/2]+f[i/3]+f[i/4]));
  12. }
  13. cout<<f[n];
  14. }
  15.  
  16. int main() {
  17. int n=23;
  18. divMax(n);
  19. // your code goes here
  20. return 0;
  21. }
Success #stdin #stdout 0s 4536KB
stdin
Standard input is empty
stdout
23