#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
int max(int a,int b)
{
if(a>b) return a;
else return b;
}
int f(int n,int val[])
{
int a,b,c,d;
if(n==0){val[n]=0; return val[n];}
else if(n==1){val[n]=1; return val[n];}
else if(n==2){val[n]=2; return val[n];}
else if(val[n]!=0) {return val[n];}
else {b=f(n/2,val);
c=f(n/3,val);
d=f(n/4,val);
a= max(n,b+c+d);
val[n]=a;
return a;}
}
main()
{
int n,ab;
int val[10000]={0};
while(cin>>n) {ab=f(n,val);cout<<ab<<endl;}
// cout<<f(12)<<endl;
}
Problem??
asked
31 Mar '12, 01:42
2★cstdio
1●1●1●5
accept rate:
0%
Please format your code properly and post.
Yes problem, your code is UNREADABLE