Comments

No, I meant exactly what I wrote

Is there a greedy solution for problem C? If no can you prove it?

https://ideone.com/VTSzgt alternative solution for problem C with time complexity O(log(a)) for query(because of gcd)

why in problem D the harmonic series is estimated as log n? (I would like to see the proof)