Firstly, the input format is k then n then finally a.
Next, you need to understand the basic idea behind solving the problem. All that’s inside is, every time the count of particles in any cell becomes greater than n, the number of particles in that cell becomes 0 and one particle is carried over to next cell.
Lets take an example of k = 4 , n = 1 , a = 3.
1: 0 0 0 //initially
2: 1 0 0
3: 0 1 0
4: 1 1 0
5: 0 0 1
Observing this one can see that for each cell, final number of particles become:
(number of particles bombarded on it) mod n
and the number of particles carried to next cell is
(number of particles bombarded on it) /(integer division) n
and for each cell the number of particles carried to it by the last cell becomes the number of particles bombarded on it.