CF333C.Lucky Tickets

省选/NOI-

通过率:0%

时间限制:6.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Gerald has a friend, Pollard. Pollard is interested in lucky tickets (ticket is a sequence of digits). At first he thought that a ticket is lucky if between some its digits we can add arithmetic signs and brackets so that the result obtained by the arithmetic expression was number 100. But he quickly analyzed all such tickets and moved on to a more general question. Now he explores k-lucky tickets.

Pollard sais that a ticket is k-lucky if we can add arithmetic operation signs between its digits to the left or right of them (i.e., "+", "-", " × ") and brackets so as to obtain the correct arithmetic expression whose value would equal k. For example, ticket "224201016" is 1000-lucky as ( - 2 - (2 + 4)) × (2 + 0) + 1016 = 1000.

Pollard was so carried away by the lucky tickets that he signed up for a seminar on lucky tickets and, as far as Gerald knows, Pollard will attend it daily at 7 pm in some famous institute and will commute to it in the same tram for m days. In this tram tickets have eight digits. And Gerald wants to make a surprise for Pollard: each day Pollard will receive a tram k-lucky ticket. The conductor has already agreed to give Pollard certain tickets during all these m days and he only wants Gerald to tell him what kind of tickets to give out. In this regard, help Gerald pick exactly m distinct k-lucky tickets.

杰拉尔德有一位朋友波拉德。波拉德对“幸运车票”(车票是一串数字)很感兴趣。起初,他认为一张车票是幸运的,当且仅当能在其某些数字之间添加算术运算符和括号,使得所得算术表达式的值恰好为 100。但他很快穷举分析了所有此类车票,继而转向一个更一般化的问题:如今他开始研究 k-幸运车票。

波拉德定义:一张车票是 k-幸运的,当且仅当我们可以在其各位数字之间(或数字左侧、右侧)添加算术运算符(即 “+”、“−”、“×”)以及括号,从而构成一个合法的算术表达式,其值恰好等于 k。例如,车票 "224201016" 是 1000-幸运的,因为

(−2−(2+4))×(2+0)+1016=1000.(-2-(2+4))\times(2+0)+1016=1000.

波拉德对幸运车票如此着迷,以至于报名参加了一场关于幸运车票的研讨会;据杰拉尔德所知,波拉德将在某著名研究所每天晚上 7 点准时参加该研讨会,并连续 m 天都乘坐同一辆有轨电车前往。而这辆电车的车票均为八位数字。杰拉尔德想给波拉德一个惊喜:在接下来的 m 天里,波拉德每天收到的车票都是一张 k-幸运车票。售票员已同意在全部 m 天内向波拉德发放指定的车票,他只希望杰拉尔德告诉他每天应发放哪张车票。为此,请帮助杰拉尔德挑选出 恰好 m 张互不相同的 k-幸运车票。

输入格式

The single line contains two integers k and m (0 ≤ k ≤ 104, 1 ≤ m ≤ 3·105).

单行包含两个整数 kk 和 mm(0 ≤ k ≤ 1040 \leq k \leq 10^4,1 ≤ m ≤ 3⋅1051 \leq m \leq 3\cdot10^5)。

输出格式

Print m lines. Each line must contain exactly 8 digits — the k-winning ticket. The tickets may begin with 0, all tickets must be distinct. If there are more than m distinct k-lucky tickets, print any m of them. It is guaranteed that at least m distinct k-lucky tickets exist. The tickets can be printed in any order.

输出 m 行。每行必须恰好包含 8 位数字——即一个 k-winning(k 获胜)票号。票号可以以 0 开头,且所有票号必须互不相同。若存在多于 m 个互不相同的 k-lucky(k 幸运)票号,则任选其中 m 个输出即可。题目保证至少存在 m 个互不相同的 k-lucky 票号。票号的输出顺序可以任意。

输入输出样例

  • 输入#1

    0 3

    输出#1

    00000000
    00000001
    00000002
  • 输入#2

    7 4

    输出#2

    00000007
    00000016
    00000017
    00000018

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

首页