The following is an implementation of the problem from spoj:- http://ift.tt/1qCBSzh
#include <stdio.h>
#define ll long long
ll arr[100000];
ll max(ll n)
{
if(n<49999)// Doubt
{
if(!arr[n])
return arr[n] = max(n/2)+max(n/3)+max(n/4);
else
return arr[n];
}
else
return max(n/2)+max(n/4)+max(n/3);
}
int main()
{
ll n,c=0,i;
for(i=0;i<12;i++)
{
arr[i]=i;
}
while(scanf("%lld",&n)!=EOF)
{
printf("%lld\n",max(n));
}
return 0;
}
Why does the if condition contain n<49999?
Aucun commentaire:
Enregistrer un commentaire