Broken Rounding

AtCoder
IDabc273_b
Time2000ms
Memory256MB
Difficulty
Given a non-negative integer $X$, perform the following operation for $i=1,2,\dots,K$ in this order and find the resulting $X$. * Round $X$ off to the nearest $10^i$. * Formally, replace $X$ with $Y$ that is "the largest multiple of $10^i$ that minimizes $|Y-X|$." * Here are some examples: * Rounding $273$ off to the nearest $10^2$ yields $300$. * Rounding $999$ off to the nearest $10^3$ yields $1000$. * Rounding $100$ off to the nearest $10^{10}$ yields $0$. * Rounding $1015$ off to the nearest $10^1$ yields $1020$. ## Constraints * $X$ and $K$ are integers. * $0 \le X < 10^{15}$ * $1 \le K \le 15$ ## Input The input is given from Standard Input in the following format: $X$ $K$ [samples]
Samples
Input #1
2048 2
Output #1
2100

$X$ changes as $2048 \rightarrow 2050 \rightarrow 2100$ by the operations.
Input #2
1 15
Output #2
0
Input #3
999 3
Output #3
1000
Input #4
314159265358979 12
Output #4
314000000000000

$X$ may not fit into a $32$\-bit integer type.
API Response (JSON)
{
  "problem": {
    "name": "Broken Rounding",
    "description": {
      "content": "Given a non-negative integer $X$, perform the following operation for $i=1,2,\\dots,K$ in this order and find the resulting $X$. *   Round $X$ off to the nearest $10^i$.     *   Formally, replace $X$ ",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc273_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Given a non-negative integer $X$, perform the following operation for $i=1,2,\\dots,K$ in this order and find the resulting $X$.\n\n*   Round $X$ off to the nearest $10^i$.\n    *   Formally, replace $X$ ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments