Difference between almost similar codes for the problem Nuclear Reactors

For the problem Nuclear Reactors : NUKES Problem - CodeChef

What is the difference between the following two codes?

The first one is a submitted solution and second one is my solution.

First Solution - Accepted Solution :

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    long long int A,N,K,i;
    scanf("%lld %lld %lld",&A,&N,&K);
    for(i=0;i<K;i++)
    {
                printf("%lld ",A%(N+1));    
                A=A/(N+1);
                
    }
    printf("\n");
    
}

Second Solution - Rejected Solution :

#include<stdio.h>
int main()
{
    long long int a,n,k;
    scanf("%lld%lld%lld",&a,&n,&k);
    for(int i=0;i<k;i++)
    {
        printf("%lld",a%(n+1));
        a=a/(n+1);
    }
    printf("\n");
}

The second code should be printf("%lld ",a%(n+1));. You forgot to put a space after %lld. Otherwise you will get you answers as 121231231 instead of 12 123 12 31.

2 Likes