Need help with NUKES

https://www.codechef.com/viewsolution/19952275

Getting the test case correct, any more ideas for testcases that is not matching my logic? I can’t figure it out.

Several problems with that code. I suggest you create a couple of tables of test cases for different particle (A) values for a fixed system - for example, with input like “A 2 3”:

A    output
0    0 0 0
1    1 0 0
2    2 0 0
3    0 1 0
4    1 1 0
5    2 1 0
6    0 2 0
7    1 2 0
8    2 2 0
9    0 0 1
10   1 0 1

etc. That should give you some ideas.

1 Like

@joffan I got the logic. This seems to be much more arithmetic than my plain mechanical solution and is much more efficient as well. Thanks a lot for pointing it out. I would still want to implement it mechanically sometime but I suspect a few TLEs will be in order.

Yes, you already had TLEs in a couple of cases from the modelling version. But you were lucky not to have run-time errors - your incrementing bug meant you didn’t find your bug accessing beyond end of array.

@joffan can u help me with this my soln is not passing only one test case
#include <stdio.h>

int main(void) {
// your code goes here
long long int a;
scanf("%lld",&a);
int n,k;
scanf("%d%d",&n,&k);
int chamber[k];
for(int i=0;i<k;i++){
chamber[i]=0;
}
while(a–){
int i=0;
chamber[i]++;
if(chamber[i]>n){
sos:
chamber[i]=0;
i++;
chamber[i]+=1;
if(chamber[i]>n) goto sos;
}

}
for(int i=0;i<k;i++){
     printf("%d ",chamber[i]);
 } 
return 0;

}