Counting Stars
CodeChefOpen on judge ↗
In a galaxy far away, space is D-dimensional and folds like donuts. There are K types of stars in the galaxy. The stars are arranged in an M x M x M ... X M (D times) hypercube, where M = 3^N. Thus, there are 3^(N*D) stars. You will be given N to specify M. As we said, space folds like donuts. Let's see what that means. There are D dimensions, named from 1 ... D. Stars in a row along dimension 1
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