Non-Increasing Number

AtCoder
IDabc443_f
Time2000ms
Memory256MB
Difficulty
A positive integer $X$ is called a **good integer** if and only if it satisfies the following condition: * When $X$ is written in decimal notation, the ones digit, tens digit, $\ldots$ form a non-increasing sequence. * More formally, the unique non-negative integer sequence $(d_0,d_1,\ldots)$ satisfying $\displaystyle X=\sum_{i=0}^{\infty} d_i10^i$ $(0\le d_i < 10)$ forms a non-increasing sequence. For example, $112389$, $1$, and $777$ are good integers, but $443$ and $404$ are not good integers. You are given a positive integer $N$. Determine whether there exists a good integer that is a multiple of $N$, and if it exists, find its minimum value. ## Constraints * $1\le N\le 3\times 10^6$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $N$ [samples]
Samples
Input #1
21
Output #1
126

$126$ is a multiple of $21$, and we have $6 \geq 2 \geq 1 \geq 0 \geq \ldots$, so it is a good integer. There does not exist a good integer less than $126$ that is a multiple of $21$, so output $126$.
Input #2
10
Output #2
\-1
Input #3
3
Output #3
3
Input #4
1089
Output #4
9999999999999999999999

The answer may be $2^{64}$ or greater.
API Response (JSON)
{
  "problem": {
    "name": "Non-Increasing Number",
    "description": {
      "content": "A positive integer $X$ is called a **good integer** if and only if it satisfies the following condition: *   When $X$ is written in decimal notation, the ones digit, tens digit, $\\ldots$ form a non-i",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc443_f"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "A positive integer $X$ is called a **good integer** if and only if it satisfies the following condition:\n\n*   When $X$ is written in decimal notation, the ones digit, tens digit, $\\ldots$ form a non-i...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments