A. Lucky Year

Codeforces
IDCF808A
Time1000ms
Memory256MB
Difficulty
implementation
English · Original
Chinese · Translation
Formal · Original
Apart from having lots of holidays throughout the year, residents of Berland also have whole _lucky_ years. Year is considered _lucky_ if it has no more than _1_ non-zero digit in its number. So years 100, 40000, 5 are _lucky_ and 12, 3001 and 12345 are not. You are given current year in Berland. Your task is to find how long will residents of Berland wait till the next _lucky_ year. ## Input The first line contains integer number _n_ (1 ≤ _n_ ≤ 109) — current year in Berland. ## Output Output amount of years from the current year to the next _lucky_ one. [samples] ## Note In the first example next _lucky_ year is 5. In the second one — 300. In the third — 5000.
除了全年有许多假期外,Berland 的居民还拥有整年的 _幸运年_。如果一个年份的数字中至多包含 _1_ 个非零数字,则该年份被视为 _幸运年_。因此,年份 100、40000、5 是 _幸运年_,而 12、3001 和 12345 则不是。 给你 Berland 的当前年份。你的任务是找出居民们需要等待多少年才能迎来下一个 _幸运年_。 第一行包含整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 109]) —— Berland 的当前年份。 请输出从当前年份到下一个 _幸运年_ 所需的年数。 在第一个例子中,下一个 _幸运年_ 是 5。在第二个例子中是 300。在第三个例子中是 5000。 ## Input 第一行包含整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 109]) —— Berland 的当前年份。 ## Output 请输出从当前年份到下一个 _幸运年_ 所需的年数。 [samples] ## Note 在第一个例子中,下一个 _幸运年_ 是 5。在第二个例子中是 300。在第三个例子中是 5000。
**Definitions** Let $ n \in \mathbb{Z} $, $ 1 \leq n \leq 10^9 $, denote the current year. A year $ y \in \mathbb{Z}^+ $ is *lucky* if its decimal representation contains at most one non-zero digit, i.e., $ y = d \cdot 10^k $ for some $ d \in \{1, 2, \dots, 9\} $ and $ k \in \mathbb{Z}_{\geq 0} $. **Constraints** $ 1 \leq n \leq 10^9 $ **Objective** Find the smallest lucky year $ y $ such that $ y > n $, and compute $ y - n $.
Samples
Input #1
4
Output #1
1
Input #2
201
Output #2
99
Input #3
4000
Output #3
1000
API Response (JSON)
{
  "problem": {
    "name": "A. Lucky Year",
    "description": {
      "content": "Apart from having lots of holidays throughout the year, residents of Berland also have whole _lucky_ years. Year is considered _lucky_ if it has no more than _1_ non-zero digit in its number. So years",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF808A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Apart from having lots of holidays throughout the year, residents of Berland also have whole _lucky_ years. Year is considered _lucky_ if it has no more than _1_ non-zero digit in its number. So years...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "除了全年有许多假期外,Berland 的居民还拥有整年的 _幸运年_。如果一个年份的数字中至多包含 _1_ 个非零数字,则该年份被视为 _幸运年_。因此,年份 100、40000、5 是 _幸运年_,而 12、3001 和 12345 则不是。\n\n给你 Berland 的当前年份。你的任务是找出居民们需要等待多少年才能迎来下一个 _幸运年_。\n\n第一行包含整数 #cf_span[n] (#cf_s...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z} $, $ 1 \\leq n \\leq 10^9 $, denote the current year.  \nA year $ y \\in \\mathbb{Z}^+ $ is *lucky* if its decimal representation contains at most one non-zero digi...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments