← All problemsSign in

Chef and Closure

CodeChefRating 1777Open on judge ↗

You are given an array $A$ with $N$ integers. You have to tell Chef whether this array is closed under multiplication. We say that an array is closed under multiplication if, for all sequences $1 \leq S_1 \lt S_2 \lt \dots \lt S_k \leq N$, there exists $1 \leq x \leq N$ such that $A_{S_1} \cdot A_{S_2} \cdot \dots \cdot A_{S_k} = A_x$. Output 1 if it is closed, and 0 otherwise. ### Input - T

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