← All problemsSign in

Chef and Gcd Queries

CodeChefRating 2002Open on judge ↗

Chef likes solving problems involving a lot of queries with numbers. One day, he found a new problem which he finds difficult to solve. Therefore, he's asking for your help! You are given a sequence A1, A2, ..., AN and Q queries. There are two types of queries: - 1 X Y — Set AX = Y. - 2 L R G — Compute the number of indices i such that L ≤ i ≤ R and gcd(G, Ai) = 1. Find the answer to each quer

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start