C. Classroom Watch

Codeforces
IDCF876C
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_.
八年级学生沃瓦今天值日。下课后,他走进办公室擦黑板,发现上面写着一个数字 #cf_span[n]。他问这是什么数字,数学老师伊娜·彼得罗夫娜告诉他,#cf_span[n] 是一道给一年级学生的算术题的答案。教材中给出了某个 *正整数* #cf_span[x],题目要求将 #cf_span[x] 加上其十进制表示下各位数字之和。 由于黑板上的数字 #cf_span[n] 很小,沃瓦很快猜出了教材中可能的 #cf_span[x]。现在他希望得到一个程序,对于任意给定的 #cf_span[n],找出所有满足条件的 #cf_span[x],或确定这样的 #cf_span[x] 不存在。请为沃瓦编写这样一个程序。 第一行包含一个整数 #cf_span[n](#cf_span[1 ≤ n ≤ 109])。 第一行输出一个整数 #cf_span[k] —— 满足条件的不同 #cf_span[x] 值的个数。 接下来的 #cf_span[k] 行,按升序输出这些值。 在第一个测试用例中,#cf_span[x = 15] 是唯一解:#cf_span[15 + 1 + 5 = 21]。 在第二个测试用例中,不存在这样的 #cf_span[x]。 ## Input 第一行包含一个整数 #cf_span[n](#cf_span[1 ≤ n ≤ 109])。 ## Output 第一行输出一个整数 #cf_span[k] —— 满足条件的不同 #cf_span[x] 值的个数。接下来的 #cf_span[k] 行,按升序输出这些值。 [samples] ## Note 在第一个测试用例中,#cf_span[x = 15] 是唯一解:#cf_span[15 + 1 + 5 = 21]。在第二个测试用例中,不存在这样的 #cf_span[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** We seek all $ x \in \mathbb{Z}^+ $ such that: $$ x + s(x) = n $$ **Objective** Find the number $ k $ of such $ x $, and output them in ascending order. If no such $ x $ exists, output $ k = 0 $.
Samples
Input #1
21
Output #1
1
15
Input #2
20
Output #2
0
API Response (JSON)
{
  "problem": {
    "name": "C. 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": "CF876C"
  },
  "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": "八年级学生沃瓦今天值日。下课后,他走进办公室擦黑板,发现上面写着一个数字 #cf_span[n]。他问这是什么数字,数学老师伊娜·彼得罗夫娜告诉他,#cf_span[n] 是一道给一年级学生的算术题的答案。教材中给出了某个 *正整数* #cf_span[x],题目要求将 #cf_span[x] 加上其十进制表示下各位数字之和。\n\n由于黑板上的数字 #cf_span[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**  \nWe seek all $ x \\in \\mathb...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments