Hi Codeforces! I was wondering if we could compute a ^ (a + b) ^ (a + 2b) ^ ... ^ (a + kb) in O(1) or such. Thought about it a lot but still I have no solutions :( Do you have any idea? Thank you!
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
Hi Codeforces! I was wondering if we could compute a ^ (a + b) ^ (a + 2b) ^ ... ^ (a + kb) in O(1) or such. Thought about it a lot but still I have no solutions :( Do you have any idea? Thank you!
Name |
---|
I didn't quite get the idea. Can you explain it more detailed?
Fine, here you go.
There are three parameters:
a
,b
andk
. Let us first learn how to solve simpler problems by fixing some of the parameters to some small values.With
a = 1
,k = 1
, solve the problemf (b) = a ^ (a + b) ^ (a + 2b) ^ ... ^ (a + kb)
. Output the first few values and observe.Once you have the solution for the simpler problem, you can return
a
andk
as parameters. Fora
, it is justg (a, b) = f (b) - f (a - 1)
. Fork
, it is perhapsh (a, b, k) = g (a, b) * k
or something similar.If
a = 1
,k = 1
then obviouslyf(b) = 1 ^ (b + 1)
, I guess?If so then g(a, b) as provided by you is wrong, I suppose.
Ow, sorry, I mixed up the letters
b
andk
. The interesting problem reduction isf (k)
fora = 1
,b = 1
, notf (b)
fora = 1
,k = 1
. Then returna
andb
into the picture.I could not figure out any way to restore
b
. It seems even witha = 1
it has no pattern at all?http://mirror.codeforces.com/blog/entry/2154
UPD: seems like I mixed the letters up as well