No.3316 Make 81181819 with only 0,1,or 8
タグ : / 解いたユーザー数 47
作問者 :
kazuppa
/ テスター :
DeltaStruct
ゆにたりー卿
Andrew8128
のらら
Rice_tawara459
👑 This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
Problem Statement
On Planet Iwai, inspired by the name of yiwiy9 (Waiiwaiwai Nine), who is very active on Earth, a game of making 81181819 from 0, 1, and 8 in as few steps as possible is popular. Let us actually try this game ourselves.
You are given a non-negative integer $N$ less than $81181819$.
Among the sequences of positive integers $p_1,p_2,...,p_k$ satisfying all of the following conditions, output one with the minimum $k$.
- $\displaystyle\sum_{i=1}^k p_i +N=81181819$
- When $p_i$ is written in decimal notation, it consists only of $0,1,8$.
If there are multiple such $p$ with the minimum $k$ satisfying the conditions, you may output any of them.
You are given $T$ test cases; answer all of them.
Constraints
- $1\leq T\leq 10$
- $0\leq N< 81181819$
- All inputs are integers.
Input
The input is given from standard input in the following format. $TestCase_k$ denotes the $k$-th test case.$T$ $TestCase_1$ $TestCase_2$ $\vdots$ $TestCase_T$
Each test case is given in the following format.
$N$
Output
For the $T$ test cases, output the answers in order to standard output, separated by newlines. For each test case, output $k$ and the sequence $p_1,p_2,...,p_k$ of length $k$ in the following format.
$k$ $p_1$ $p_2$ $\vdots$ $p_k$Print a newline at the end.
Sample
Sample
Input
4 81181805 81181798 81181638 0
Output
4 1 1 1 11 2 11 10 1 181 2 81181818 1
For the first case:
- $p=(-8,11,11)$ is invalid, because $p$ must be a sequence of positive integers.
- $p=(11,1)$ is invalid, because $\displaystyle\sum_{i=1}^k p_i +N=81181819$ must hold.
- $p=(13,1)$ is invalid, because $p_1$ contains $3$ when written in decimal notation.
- $p=(8,1,1,1,1,1,1)$ is invalid, because its $k$ is not the minimum among the sequences $p$ satisfying the conditions.
$p=(11,1,1,1)$ is also a solution, so you may output this as well.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。