In last two contest problem "C" was quite easy but how you guys come up to the logic?! I just cannot figured it out,Is there any good books or something which can improve my logical thinking about those math type problem? Problem link: In codecraft-20 1316C - Primitive Primes and in Ozon tech challenge 1305C - Kuroni and Impossible Calculation
Instead of blindly solving, try to understand the proof behind stuff and you realize the proofs for some problems are quite similar.