@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.
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.
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 ))
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?
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.