#P5261. [JSOI2013] 数字理论
[JSOI2013] 数字理论
Problem Description
Given four positive integers , in decimal, find the smallest -digit natural number such that the sum of digits of is , and the sum of digits of is .
Input Format
The input contains one line with four integers: .
Output Format
Output one integer in one line, representing the smallest natural number that satisfies the conditions. If it does not exist, output .
2 9 9 5
18
Hint
Constraints: $1~\leq~K~\leq~100,~1~\leq~S,~P~\leq~1000,~1~\leq~D~\leq~9$.
Translated by ChatGPT 5