CODE1 in SPOJ - can't solve it

I am trying to solve the secret code of the SPOJ problem, and this is obviously a mathematical problem.

Complete problem

For those who are lazy to go and read, this is so:

a0, a1, a2, ..., an - sequence of N numbers B - a Complex Number (has both real and imaginary components) X = a0 + a1*B + a2*(B^2) + a3*(B^3) + ... + an*(B^n) 

So, if you are given B and X, you must find a0, a1, .. an. I don’t know how and where to start, because even N is not known, just X and B.

The problem is not as simple as expressing a number in the base of B, since B is a complex number.

How can this be solved?

+4
source share
1 answer

The key is that a0 .. an are not arbitrary numbers, they are integers (otherwise it would be impossible at all). You are assigned the number X , and he is asked to express it in base B Why don't you start with a few examples for a specific value of B ?

If I asked you to write 17 in base 2, could you do this? Can you find a way to generalize the algorithm that you use for bases other than 2?

+7
source

Source: https://habr.com/ru/post/1304305/


All Articles