A. Classroom Watch

Codeforces
IDCF875A
Time1000ms
Memory512MB
Difficulty
brute forcemath
English · Original
Chinese · Translation
Formal · Original
Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number _n_. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that _n_ is the answer to the arithmetic task for first-graders. In the textbook, a certain **positive integer** _x_ was given. The task was to add _x_ to the sum of the digits of the number _x_ written in decimal numeral system. Since the number _n_ on the board was small, Vova quickly guessed which _x_ could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number _n_ for all suitable values of _x_ or determine that such _x_ does not exist. Write such a program for Vova. ## Input The first line contains integer _n_ (1 ≤ _n_ ≤ 109). ## Output In the first line print one integer _k_ — number of different values of _x_ satisfying the condition. In next _k_ lines print these values in ascending order. [samples] ## Note In the first test case _x_ = 15 there is only one variant: 15 + 1 + 5 = 21. In the second test case there are no such _x_.
八年级学生沃瓦今天值日。下课后,他走进办公室擦黑板,发现上面写着数字 $n$。他问这是什么数字,数学老师伊娜·彼得罗夫娜告诉他,$n$ 是一道给一年级学生的算术题的答案。课本中给出某个 *正整数* $x$,题目要求将 $x$ 加上其十进制表示下各位数字之和。 由于黑板上的数字 $n$ 很小,沃瓦很快就猜出了课本中可能的 $x$。现在他希望得到一个程序,对于任意给定的 $n$,找出所有满足条件的 $x$ 的值,或确定这样的 $x$ 不存在。请为沃瓦编写这样一个程序。 第一行包含整数 $n$($1 ≤ n ≤ 10^9$)。 第一行输出一个整数 $k$ —— 满足条件的不同 $x$ 值的个数。 接下来 $k$ 行,按升序输出这些 $x$ 值。 在第一个测试用例中,$x = 15$ 是唯一解:$15 + 1 + 5 = 21$。 在第二个测试用例中,不存在这样的 $x$。 ## Input 第一行包含整数 $n$($1 ≤ n ≤ 10^9$)。 ## Output 第一行输出一个整数 $k$ —— 满足条件的不同 $x$ 值的个数。接下来 $k$ 行,按升序输出这些 $x$ 值。 [samples] ## Note 在第一个测试用例中,$x = 15$ 是唯一解:$15 + 1 + 5 = 21$。在第二个测试用例中,不存在这样的 $x$。
**Definitions** Let $ n \in \mathbb{Z}^+ $ with $ 1 \leq n \leq 10^9 $. Let $ s(x) $ denote the sum of the decimal digits of $ x \in \mathbb{Z}^+ $. **Constraints** Find all positive integers $ x $ such that: $$ x + s(x) = n $$ **Objective** Determine the set $ X = \{ x \in \mathbb{Z}^+ \mid x + s(x) = n \} $. Output: - $ k = |X| $, the number of such $ x $, - followed by the elements of $ X $ in ascending order.
Samples
Input #1
21
Output #1
1
15
Input #2
20
Output #2
0
API Response (JSON)
{
  "problem": {
    "name": "A. Classroom Watch",
    "description": {
      "content": "Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number _n_. He asked what is this number and the teacher of mathematics ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 524288
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF875A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number _n_. He asked what is this number and the teacher of mathematics ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "八年级学生沃瓦今天值日。下课后,他走进办公室擦黑板,发现上面写着数字 $n$。他问这是什么数字,数学老师伊娜·彼得罗夫娜告诉他,$n$ 是一道给一年级学生的算术题的答案。课本中给出某个 *正整数* $x$,题目要求将 $x$ 加上其十进制表示下各位数字之和。\n\n由于黑板上的数字 $n$ 很小,沃瓦很快就猜出了课本中可能的 $x$。现在他希望得到一个程序,对于任意给定的 $n$,找出所有满足条件的 ...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ with $ 1 \\leq n \\leq 10^9 $.  \nLet $ s(x) $ denote the sum of the decimal digits of $ x \\in \\mathbb{Z}^+ $.  \n\n**Constraints**  \nFind all positive integers...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments