|
|
back to boardShow all messages Hide all messagesI don't understand, how it is possible to get the answer for the test 50000 3 3 3 3 ... 3 3^50000 has length around 23856. How do it fast, so it can pass the time limit? Maybe there are some trick there. Long multiplication takes very long time, to do it 50000 times. I used just long by short (< 2^63) multiplication. Calculate it as ((3^2)^2 * 3)^2 * 3 for 3^11. For calculating product, do we have to see how many consecutive numbers are same so as to calculate product of them by logarithmic power method? Because I see no other way to use the power method of logarithmic time... Note, that given "an integer not exceeding 3 in absolute value" Edited by author 01.01.2009 16:16 x = 3^50000 does x have length 23856 or 23857? does it start in 115 and end in 761000001? |
|
|