Chef and Modular Sequence
You are given an integer $A$. Let's define an infinite sequence $S(A) = A\%P, A^2\%P, A^3\%P, \ldots$, where $P = 10^8+7$ is a prime and $\%$ is the modulo operator. Let's also define a decreasing sum $D(S)$ as the sum of all elements of a sequence $S$ which are strictly smaller than all preceding elements of $S$. When $S$ is a sequence of non-negative integers, the number of such elements is c
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.
Sign in to chat with the tutor and save your progress.
Sign in to start