B. Perfect Number

Codeforces
IDCF919B
Time2000ms
Memory256MB
Difficulty
binary searchbrute forcedpimplementationnumber theory
English · Original
Chinese · Translation
Formal · Original
We consider a positive integer perfect, if and only if the sum of its digits is exactly $10$. Given a positive integer $k$, your task is to find the $k$\-th smallest perfect positive integer. ## Input A single line with a positive integer $k$ ($1 \leq k \leq 10\,000$). ## Output A single number, denoting the $k$\-th smallest perfect integer. [samples] ## Note The first perfect integer is $19$ and the second one is $28$.
我们称一个正整数为“完美”的,当且仅当它的各位数字之和恰好为 $10$。给定一个正整数 $k$,你的任务是找出第 $k$ 小的完美正整数。 一行包含一个正整数 $k$($1 lt.eq k lt.eq 10 thin 000$)。 输出一个数,表示第 $k$ 小的完美整数。 第一个完美整数是 $19$,第二个是 $28$。 ## Input 一行包含一个正整数 $k$($1 lt.eq k lt.eq 10 thin 000$)。 ## Output 输出一个数,表示第 $k$ 小的完美整数。 [samples] ## Note 第一个完美整数是 $19$,第二个是 $28$。
**Definitions** Let $ S = \{ n \in \mathbb{Z}^+ \mid \text{sum of digits of } n = 10 \} $. Order $ S $ in increasing order: $ s_1 < s_2 < s_3 < \cdots $. **Constraints** $ 1 \leq k \leq 10{,}000 $ **Objective** Find $ s_k $, the $ k $-th smallest element of $ S $.
Samples
Input #1
1
Output #1
19
Input #2
2
Output #2
28
API Response (JSON)
{
  "problem": {
    "name": "B. Perfect Number",
    "description": {
      "content": "We consider a positive integer perfect, if and only if the sum of its digits is exactly $10$. Given a positive integer $k$, your task is to find the $k$\\-th smallest perfect positive integer.",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF919B"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "We consider a positive integer perfect, if and only if the sum of its digits is exactly $10$. Given a positive integer $k$, your task is to find the $k$\\-th smallest perfect positive integer.\n\n## Inpu...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "我们称一个正整数为“完美”的,当且仅当它的各位数字之和恰好为 $10$。给定一个正整数 $k$,你的任务是找出第 $k$ 小的完美正整数。\n\n一行包含一个正整数 $k$($1 lt.eq k lt.eq 10 thin 000$)。\n\n输出一个数,表示第 $k$ 小的完美整数。\n\n第一个完美整数是 $19$,第二个是 $28$。\n\n## Input\n\n一行包含一个正整数 $k$($1 lt.eq ...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ S = \\{ n \\in \\mathbb{Z}^+ \\mid \\text{sum of digits of } n = 10 \\} $.  \nOrder $ S $ in increasing order: $ s_1 < s_2 < s_3 < \\cdots $.\n\n**Constraints**  \n$ 1 \\leq k \\leq 10{,}00...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments