← All problemsSign in

Minimal Weighted Digit Sum

Let M be a fixed positive integer. Your task is for each R from 0 to M − 1, inclusive, find the minimal non-negative integer having residue R modulo M and having the minimal weighted digit sum. Namely, let W[0], W[1], ..., W[9] be the sequence of weights assigned to the decimal digits. For positive integer N having decimal representation D1D2...DK the weighted digit sum of N is the number WS(N) =

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