Yet Another Mod Mod Mod
CodeChefOpen on judge ↗
You are given $n$ numbers $a_1,a_2, ... a_n$ and another number $x$. Let $P= p_1,p_2,...p_n$ be any permutation of $1,2,...n$. Your task is to find the number of distinct values of $((((x\%a_{p_1})\%a_{p_2})\%a_{p_3}...)\%a_{p_n}$ ### Input: - The first line contains $T$, the number of testcases. - There are two lines in each testcase. The first line contains the numbers $n$ and $x$. - The se
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