Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  var
Language: C/C++
Code:
#include<stdio.h>
#define MAX(a,b)  a>b?a:b
unsigned int a[1000] = {0};
unsigned long  int s, i;


unsigned long int ret( unsigned long int n)
{
s=0;
if( n<4)
return n;
else
{
if( n>0 && n<=1000)
{
if(a[n])
return a[n];
}
else
{
s= ret(n/2) + ret(n/3) + ret(n/4);
a[n]= MAX(s,n);
return a[n];
}
}
}

int main()
{
unsigned long int n;
while( scanf("%lu", &n)!= EOF)
{
printf( "%lut", ret(n));
}

return 0;
}
     
          
Comments: