CF1567D.Expression Evaluation Error

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

On the board, Bob wrote nn positive integers in base 1010 with sum ss (i. e. in decimal numeral system). Alice sees the board, but accidentally interprets the numbers on the board as base-1111 integers and adds them up (in base 1111).

What numbers should Bob write on the board, so Alice's sum is as large as possible?

在黑板上,鲍勃用十进制(即位值记数法中的底数为 1010)写下了 nn 个正整数,它们的和为 ss。爱丽丝看到了黑板,但不小心将黑板上的数字误认为是十一进制(base-1111)整数,并在十一进制下将它们相加。

鲍勃应在黑板上写下哪些数字,才能使爱丽丝计算出的和尽可能大?

输入格式

The input consists of multiple test cases. The first line contains an integer tt (1≤t≤1001 \leq t \leq 100) — the number of test cases. The description of the test cases follows.

The only line of each test case contains two integers ss and nn (1≤s≤1091 \leq s \leq 10^9; 1≤n≤min⁡(100,s)1 \leq n \leq \min(100, s)) — the sum and amount of numbers on the board, respectively. Numbers ss and nn are given in decimal notation (base 1010).

输入包含多个测试用例。第一行包含一个整数 tt(1≤t≤1001 \leq t \leq 100),表示测试用例的数量。随后是各测试用例的描述。

每个测试用例仅有一行,包含两个整数 ss 和 nn(1≤s≤1091 \leq s \leq 10^9;1≤n≤min⁡(100,s)1 \leq n \leq \min(100, s)),分别表示黑板上所有数字的总和与数字的个数。数字 ss 和 nn 均以十进制(基数为 1010)给出。

输出格式

For each test case, output nn positive integers — the numbers Bob should write on the board, so Alice's sum is as large as possible. If there are multiple answers, print any of them.

对于每个测试用例,输出 nn 个正整数——即 Bob 应写在黑板上的数字,使得 Alice 的和尽可能大。如果存在多个答案,输出任意一个即可。

输入输出样例

  • 输入#1

    6
    97 2
    17 1
    111 4
    100 2
    10 9
    999999 3

    输出#1

    70 27 
    17 
    3 4 100 4
    10 90
    1 1 2 1 1 1 1 1 1 
    999900 90 9

说明/提示

In the first test case, 7010+2710=971070_{10} + 27_{10} = 97_{10}, and Alice's sum is $$70_{11} + 27_{11} = 97_{11} = 9 \cdot 11 + 7 = 106_{10}.$$ (Here xbx_b represents the number xx in base bb.) It can be shown that it is impossible for Alice to get a larger sum than 10610106_{10}.

In the second test case, Bob can only write a single number on the board, so he must write 1717.

In the third test case, 310+410+10010+410=111103_{10} + 4_{10} + 100_{10} + 4_{10} = 111_{10}, and Alice's sum is $$3_{11} + 4_{11} + 100_{11} + 4_{11} = 110_{11} = 1 \cdot 11^2 + 1 \cdot 11 = 132_{10}.$$ It can be shown that it is impossible for Alice to get a larger sum than 13210132_{10}.

在第一个测试用例中,7010+2710=971070_{10} + 27_{10} = 97_{10},而爱丽丝的和为

70_11+27_11=97_11=9cdot11+7=106_10.70\_{11} + 27\_{11} = 97\_{11} = 9 \\cdot 11 + 7 = 106\_{10}.

(此处 xbx_b 表示以 bb 为进制的数 xx。)可以证明,爱丽丝无法得到大于 10610106_{10} 的和。

在第二个测试用例中,鲍勃只能在黑板上写一个数,因此他必须写 1717。

在第三个测试用例中,310+410+10010+410=111103_{10} + 4_{10} + 100_{10} + 4_{10} = 111_{10},而爱丽丝的和为

3_11+4_11+100_11+4_11=110_11=1cdot112+1cdot11=132_10.3\_{11} + 4\_{11} + 100\_{11} + 4\_{11} = 110\_{11} = 1 \\cdot 11^2 + 1 \\cdot 11 = 132\_{10}.

可以证明,爱丽丝无法得到大于 13210132_{10} 的和。

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

首页