|
|
|
|
|
by er888kh
1480 days ago
|
|
I came up with another solution (which is purposefully complicated):
It is known that the sum of n-th roots of unity is zero.
So if we choose the n-th roots of unity as ω and calculate Σ ω^ai, the result should be 0 + ω^(the duplicate number). So I opened the python interpreter, and I used this very trivial method of calculation (instead of summing the sine and cosine functions independently), and using asin and acos functions, got the result. It turned out to be accurate for n=1e6 with an error of ~1e-5. So it should be usable for much bigger n too. |
|