i am not able to understand what is happening during bombardment what happens in this reaction, what new particles are made???
You have K empty chambers at the beggining
0 0 ... 0 (0xk)
next you A-times bombard first chamber
1 0 ... 0
2 0 ... 0
3 0 ... 0
and so on…
But capacity of chamber is N (let say 4), and statement reads
However if at any time, there are more than N particles in a chamber, a reaction will cause 1 particle to move to the immediate next chamber
so if I continue in previous example
3 0 ... 0
4 0 ... 0
5 0 ... 0 (rule is applied) -> 4 1 ... 0
and so on
5 1 ... 0 -> 4 2 ... 0
5 2 ... 0 -> 4 3 ... 0
5 3 ... 0 -> 4 4 ... 0
5 4 ... 0 -> 4 5 ... 0 -> 4 4 1 ... 0
clear?
But A can be huge (1000000000) so you cannot make this simulation…
guidance: http://www.youtube.com/watch?v=5sS7w-CMHkU
suppose input:
25 4 4
that means A=25(bombarded particles), N=4(capacity of chamber), K=4(number of chambers)
step-by-step illustration of chambers with consisting particles in it:
1: 1 0 0 0
2: 2 0 0 0
3: 3 0 0 0
4: 4 0 0 0
5: 0 1 0 0
6: 1 1 0 0
7: 2 1 0 0
8: 3 1 0 0
9: 4 1 0 0
10: 0 2 0 0
11: 1 2 0 0
12: 2 2 0 0
13: 3 2 0 0
14: 4 2 0 0
15: 0 3 0 0
16: 1 3 0 0
17: 2 3 0 0
18: 3 3 0 0
19: 4 3 0 0
20: 0 4 0 0
21: 1 4 0 0
22: 2 4 0 0
23: 3 4 0 0
24: 4 4 0 0
25: 0 0 1 0
why this is wrong!!!
output give correct answer…
#include<stdio.h>
#include<math.h>
int main()
{
int z,j,a,n,k,p,q,i,arr[101];
scanf("%d%d%d",&a,&n,&k);
p=n+1;
q=k-1;
for(j=k-1;j>=0;j–)
{
z=pow(p,j);
arr[q]=a/z;
a=a%z;
q–;
}
for(i=0;i<=k-1;i++)
printf("%d ",arr[i]);
return 0;
}