Nuclear ReactorsProblem code: NUKES |
All submissions for this problem are available.
There are K nuclear reactor chambers labelled from 0 to K-1. Particles are bombarded onto chamber 0. The particles keep collecting in the chamber 0. 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(if current chamber is 0, then to chamber number 1), and all the particles in the current chamber will be be destroyed and same continues till no chamber has number of particles greater than N. Given K,N and the total number of particles bombarded (A), find the final distribution of particles in the K chambers. Particles are bombarded one at a time. After one particle is bombarded, the set of reactions, as described, take place. After all reactions are over, the next particle is bombarded. If a particle is going out from the last chamber, it has nowhere to go and is lost.
Input
The input will consist of one line containing three numbers A,N and K separated by spaces. A will be between 0 and 1000000000 inclusive. N will be between 0 and 100 inclusive. K will be between 1 and 100 inclusive. All chambers start off with zero particles initially.
Output
Consists of K numbers on one line followed by a newline. The first number is the number of particles in chamber 0, the second number is the number of particles in chamber 1 and so on.
Example
Input: 3 1 3 Output: 1 1 0Explanation Total of 3 particles are bombarded. After particle 1 is bombarded, the chambers have particle distribution as "1 0 0". After second particle is bombarded, number of particles in chamber 0 becomes 2 which is greater than 1. So, num of particles in chamber 0 becomes 0 and in chamber 1 becomes 1. So now distribution is "0 1 0". After the 3rd particle is bombarded, chamber 0 gets 1 particle and so distribution is "1 1 0" after all particles are bombarded one by one.
| Author: | admin |
| Date Added: | 15-07-2009 |
| Time Limit: | 1 sec |
| Source Limit: | 50001 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
Comments
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
HELP
Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.

Fetching successful submissions

it doesn't take java file. correctly.
i mean. i have tested this program but Judge fails for all testcases.
im not sure whether it is giving inputs correctly..
please provide some examples for submitting a code.
i.e. give a sample java file which takes input and prints values.
http://www.codechef.com/help/ You will find that information here.
Hi,
no matter what optimization i do for my java code, i am not able to complete 2 test cases of yours withing the time limit.
can some one help me with this.
-karthik
What is the complexity of your solution?
I have a O(log(A)) solution but still it is giving time limit exceeded. i cant believe it.
oh I was assuming multiple input line. now its fine.
@Directi Admin:
my algorithm works in 0(n), in the worst case for my implementation.
still i am not able to write within time for one of the test cases.
can i get the test data for that test case.
Thx.
-karthik
An O(n) algorithm won't work. You need a better complexity for it to pass.
hi, please check my solutions in java and c . both have same algorithm but yet java solution takes 1.95 s and c takes 0 s. are there any plans to remove this biasing?
basically are u calling the .class file from some script and measure how much script takes or u calling the static function from already running class and measuring how much the function took?
more precisely does the time include starting time of jvm or it is the more time taken by jvm for executing same instructions?
I feel there is something seriously wrong........Even with the maximum inputs my code works perfectly fast....still i am getting time limit exceeded error.........any other way to measure the time.......plz suggest
One simple way would be to check the complexity and then check if it is such that the implementation would work in time. You can try executing the code locally for the maximum sized test case and see how much time it takes.
i have tried it on my local pc with maximum input say 1000000000 100 100 on eclipse.....and i feel it hardly takes a second or so..........
And how can i check the complexity of my solution............
The complexity of your code is of a magnitude higher than O(A) and A can be as large as 10^9. You need to reduce the complexity.
I have tested my code with various test cases. It is showing correct results. But it is showing wrong answer at your end with all your test cases. Please check whether I am using Input and output correctly.
Should I display - Input : ...... next line Output : .... or just the Input values and in the next line just the output values..?
You don't need to display the input again. Just the output as specified in the problem statement. It seems you already have got this problem accepted.
I am unable to submit the
Submissions for this problem
Submissions for this problem will be made available after some days.
when will we be able to
Why can't we submit answers
Why can't we submit answers to this problem ?
Submissions will be enabled
Submissions will be enabled soon.
why has the problem been
why has the problem been removed ?
HI, I was working on this
HI,
I was working on this problem:
http://www.codechef.com/problems/NUKES/
I am not able to submit my solution. Is the Nuclear Reactor problem removed?
The problem will be up soon.
The problem will be up soon. Sorry for the inconvenience
Hi I am getting a wrong
Hi
I am getting a wrong answer for the case 10^9. what could be the possible problems? I think that the code I have implemented is correct.
The ID of my code is 190634.
The ID of my code is 190634.
I am getting a SIGFPE
I am getting a SIGFPE (Floating Point Exception) for the case 10^9. Also, the answers for all the other test cases were correct. How to deal with this??
Also, when I submitted the solution, it showed the results for different values of N, which according to me, should be A.
Regarding SIGFPE, please
Regarding SIGFPE, please don't bother anyone. Looks like C was assigning 0 to the variables that went outside the range of 'int'. Division by that variable was giving the Floating Point Exception.
@ADMIN PLZ HELP I GET SIGFPE
@ADMIN
PLZ HELP
I GET SIGFPE for A = 10^9.
BUT WHY I CAN'T SEE.
Just have a look, i've tried a lot :|
http://www.codechef.com/viewsolution/250042
@ Admin I am able to pass all
@ Admin
I am able to pass all the test cases except the third one. I have tried but I am unable to make out why, Please help. :)
oh! i got it!!
oh! i got it!!
got mine ass blown off in
got mine ass blown off in such a easy question.
tips for other people:
1)try to use log function.
2)take care of special case n=0
@ admin My code runs
@ admin My code runs successfully on my system....bt gives wrong answer whn i submit it here.
Am i too bad in algorithms or
Am i too bad in algorithms or am I correct in thinking that there is an O(K) solution to this problem?
ADMIN, m get this error
ADMIN,
m get this error many times on submitting wht does this mean
:( internal error occurred in the system.
ADMIN here is my code m
ADMIN
here is my code m getting :( internal error occurred in the system on submitting .
http://www.codechef.com/viewsolution/335549
any suggestion what might be th reason ..
ya admin me 2 getting the
ya admin me 2 getting the same result
:( internal error occurred in the system on submitting .
plzz help
Hi, on submitting my
got it atlast :) i was
ADMIN here is my code m
When I had executed the code
When I had executed the code on my system it took 0.1 sec but after submitting here I got "Time Limited Exceeded", 2.85 sec when A = 10^9 .... http://www.codechef.com/viewsolution/364999
There is more than one
There is more than one possible test case with A = 10^9. Have you tried N=1 and K=100?
//rishabh
//rishabh jain
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int a,n,k;
cin>>a>>n>>k;
for(int i=0;i<k;i++)
{
cout<<a%(n+1);
a=a/(n+1);
}
system("pause");
return 0;
}
Your code gives the wrong
Your code gives the wrong answer for the sample input. Read the FAQ if you don't know how to test your code.
@stephen : i'v tried a lot. I
@stephen : i'v tried a lot. I can't point out any error in my logic.Codechef still says my solution is incorrect :/
Please help.
#include<stdio.h>
using namespace std;
int main()
{
long int a,pow;
int n,k,i=0,q=0,g,b,t;
scanf("%ld",&a);
scanf("%d",&n);
scanf("%d",&k);
while(i<k&&n!=0) {
q=0;
pow=(n+1);
while(q<(i-1)){
pow=(n+1)*pow;
if(pow>a){break;}
q++;
}
g=(a/pow);
b=(n+1);
t=g%b;
printf("%d ",t);
i++;
}
i=0;
if(n==0){while(i<k){printf("0 ");i++;}}
return 0;
}
i don't get it!!! What's the
@ admin where is the problem
http://www.codechef.com/views
dear admin, i have been using
dear admin my code is giving
convert a number to ny base!
@rishabh: i think you should
It says TLE for N values
Hi Admin, can you check my
Hi! somebody please tell
the result list of top
There is an O(k) solution. An
hi admin... i m unable to
can any buddy please make me
@avnish_jain: until this time