there is some problem with the solution of COINS question

#include<stdio.h>
int main()
{
int n[20],n1=0,n2=0,n3=0,i,len=0;
len=sizeof(n)/sizeof(int);
printf(“pls enter any %d number:\n”,len);
for(i=0;i<len;i++)
{
scanf("%d",&n[i]);
n1=n1+(n[i]/2);
n1=n1+(n[i]/3);
n1=n1+(n[i]/4);
if(n[i]<n1)
{
n[i]=n1;
}
else
{
n[i]=n[i];
}
n1=0;
printf("%d\n",n[i]);
}
return 0;
}

there is some problem as the code above executes well then also it shows wrong answer pls help if u can

follow the input and output formats that are specified…don’t print unwanted stuff like…

printf("pls enter any %d number:\n",len);

directly take inputs and give outputs as specified…u dont need to prompt the judge for input!!!

also the algo u r using is not the correct one…this is a Dynammic Programming(DP) problem…please rethink on your logic!!!

1 Like
//