CF#538 F. Please, another Queries on Array?
https://codeforces.com/contest/1114/problem/F
My solution is the fastest on Feb 16, 2019. The discrete logarithm is one of the keys for speed. (This approach is based on deja-vu's solution.)
https://codeforces.com/contest/1114/submission/49968741 (186 ms)
https://codeforces.com/contest/1114/submission/49967877 (420 ms, don't use discrete logarithms)