← All problemsSign in

Lucky Days

CodeChefRating 2392Open on judge ↗

Chef Ciel defined a sequence S as follows: S[1] = A S[2] = B S[i] = (X*S[i-1] + Y*S[i-2] + Z) mod P, for i >= 3 Ciel considers C is a lucky number, and the i-th day is a lucky day if and only if S[i] = C. Ciel's restaurant may have special events in a lucky day. By the way, your work is calculating the numbers of lucky days in intervals. That is, for each Q intervals [L[i], R[i]], you

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