@Michael1993, mathematically your approach is correct. It probably timed-out or had memory overflow in larger scale.
Print out all numbers you got in your small-scale array, e.g. up to 10x10, or 20x20 as you like. Line up the numbers tidily as a square. Try to spot the pattern with the numbers. The pattern is something taught in school and repeatedly shows up in many puzzles.
I can just tell you that much without spoiling the puzzle.
Or solve that one and get access to the solutions forum
The solution of this problem can be reduced to using only one 1D array of BigInt. Also very important size of the BigInt objects. At first I though that my solution exceeds time limit in Megalopolis test but really problem was in size of my BigInt objects. I just reduce a bit the max number size in my BigInt class and it worked out.
I get the correct answer on the first 4 problems and it doesn’t time out on the larger problems I just get a wrong answer but I don’t know why.
What do you mean by a BigInt and how do I declare it, also what do you mean by reduce the bit? I can try the 1D array and see what I get.
Instead System.Numerics.BigInteger I used my own class BigInt. And after I reduced max size of the array that represents the big number in my class my solution worked out.
But as it turned out this task can be solved without any arrays ))
This problem is driving me crazy… I tried the 2d array.
I also tried it the math way.
((width + height -2)!) / ((width -1)! * (height - 1)!)
it passes every test but the last two.
That’s correct. Maybe you forgot that the answer need only first 1000 digits.
So I am failing the test on the bigger numbers. The last two test still fail. The smaller test pass with no problem. Here is the code that has all the math. Can anyone tell me what I might be doing wrong?
Read the previous message.
I get the having the first 1000 digits. The fifth test only has 50 digits so it will pass if a normal run, the math still says I am wrong though, that is what I am having problem on.
No matter you are using long, double, or long double, it is quite impossible for you to get 1000 accurate digits from calculation. Many of the digits at the tail you got are approximate values only.