The Link to Question is here
and my solution Link is this
https://www.codechef.com/viewsolution/27614817
I want to know in which test case my solution will fail and also what is wrong with my solution.
The Link to Question is here
and my solution Link is this
https://www.codechef.com/viewsolution/27614817
I want to know in which test case my solution will fail and also what is wrong with my solution.
At a guess, I’d say it’s because you’re mixing floating point (std::pow
) with integers, but I can’t actually find a testcase that fails (and I’ve tried over 100000 random ones!).
I want to learn how you generate random test cases and test to your solution.and yeah sometimes it’s frustating when your answer is wrong and you can’t find any bug in your code.
Not much to it, usually: see e.g. this post and some specific examples from this OCT19A:
CodeChef: Practical coding for everyone (BACREP)
CodeChef: Practical coding for everyone (MSV)
CodeChef: Practical coding for everyone (MARM)
CodeChef: Practical coding for everyone (EVEDG)
Guess what, the best possible random test case generator for such problems is a human. I figured out that b
has no contribution to any error. I’m left with n
and m
. Let’s assign the maximum possible values to n
and m
and compare the results produced by your program and mine for the test case:
n = 100000000
b = 1
m = 100000000
Your code produces : 135215232000000016
& my code produces: 135215232000000026
13 1 2
N b m
7,3,2,1
× 2, 22, 222 ,2222
.+ 1 ,1,1
Total needed minutes for jem = 103 minutes
How is the example is it helpful.