Bytelandian gold coins :WA

here my code:

#include<stdio.h>
#include<math.h>
#define max(a,b)     (a>b)? a : b
int main()
{
    long long t;
    while(scanf("%lld",&t)!=EOF)
    {
          int has=t;
          t=(t/2)+(t/3)+(t/4);
          
          printf("%lld\n",max(t,has));                        
    }   
}

i dont know what wrong with it… please help

try and rethink on the problem statement…your algo is not correct…you can divide ur amt into change many times…like…

if u have an amt n…u can divide it into n/2 n/3 & n/4

let a=n/2 b=n/3 and c=n/4

you can further divide a into a/2 a/3 & a/4…same for b and c…you need to do this until the sum of the divisions does not become optimum(constant) it is a Dynamic Programming(DP) Problem…hope this helps…:slight_smile: