CF489C.Given Length and Sum of Digits...

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.

你有一个正整数 mm 和一个非负整数 ss。你的任务是找出所有长度为 mm 且各位数字之和为 ss 的数中最小的一个和最大的一个。所求数应为非负整数,以十进制表示,且不能有前导零。

输入格式

The single line of the input contains a pair of integers m, s (1 ≤ m ≤ 100, 0 ≤ s ≤ 900) — the length and the sum of the digits of the required numbers.

输入仅包含一行,有两个整数 mm 和 ss(1 ≤ m ≤ 1001 ≤ m ≤ 100,0 ≤ s ≤ 9000 ≤ s ≤ 900),分别表示所求数字的位数和各位数字之和。

输出格式

In the output print the pair of the required non-negative integer numbers — first the minimum possible number, then — the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).

在输出中打印所需的一对非负整数——先打印最小可能的数,再打印最大可能的数。如果不存在满足条件的数,则打印一对数字“-1 -1”(不带引号)。

输入输出样例

  • 输入#1

    2 15

    输出#1

    69 96
  • 输入#2

    3 0

    输出#2

    -1 -1

输入解题思路,AI测评打分。不知道怎么写?

首页