Cakewalk problem issue

Hi,

It seems very strange to me while solving this question in beginner section Smallest Numbers of Notes.
Here are the links of my solutions that are been accepted and rejected. The only difference between two of them is that in the failed one (which I tried firstly of course!!), the data types of variables are unsigned long type and unsigned int type.

u32 is typedef unsigned long

u32 num,L,min=0, Arr[] = {1,2,5,10,50,100};

While in the accepted solution I just replaced unsigned int and unsigned long to int data-type

int num,L,min=0, Arr[] = {1,2,5,10,50,100}; 

Any idea why the last one accepted not the first one??

Even constraints are satisfies by the first solution too!!!

So the problem with your rejected code is the format specifier.
You’ve used %d for scanning and printing unsigned int which leads your code to undefined behaviour and gives wrong output ultimately.

Change the format specifier in both scanf and printf as %lu which is the format specifier for unsigned int in C and the code will run perfect.

Here’s a link to List of all format specifiers in C for future reference.

Hope this helps.