Tap here to switch tabs
Problem
Submissions

Problem: Minimum Addition to Make Integer Beautiful

Try to solve the Minimum Addition to Make Integer Beautiful problem.

Statement

You are given two positive integers n and target.

An integer is considered beautiful if the sum of its digits is less than or equal to target.

Return the minimum nonnegative integer x such that n + x is beautiful.

Constraints:

  • 1≤1 \leq n ≤1012\leq 10^{12}

  • 1≤1 \leq target ≤150\leq 150

  • The input will be generated such that it is always possible to make n beautiful.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Addition to Make Integer Beautiful

Try to solve the Minimum Addition to Make Integer Beautiful problem.

Statement

You are given two positive integers n and target.

An integer is considered beautiful if the sum of its digits is less than or equal to target.

Return the minimum nonnegative integer x such that n + x is beautiful.

Constraints:

  • 1≤1 \leq n ≤1012\leq 10^{12}

  • 1≤1 \leq target ≤150\leq 150

  • The input will be generated such that it is always possible to make n beautiful.