Friday, December 20, 2013

codechef NUKES - "nuclear reactors" problem guidance and solution

codechef NUKES - "nuclear reactors" problem: http://www.codechef.com/problems/NUKES

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


my c++ solution to codechef NUKES - "nuclear reactors" problem: http://ideone.com/7omT5g
#include <iostream>
using namespace std;

int main() {
// your code goes here
int a, n, k;
cin>>a>>n>>k;
while(k--) {
cout<<a%(n+1)<<" "; a=a/(n+1);
}
return 0;
}

1 comment:

  1. I didn't understand the relation between the video you gave the link for and the codechef question. Can you please explain a bit .

    ReplyDelete