Floor Function

AtCoder
IDabc165_d
Time2000ms
Memory256MB
Difficulty
Given are integers $A$, $B$, and $N$. Find the maximum possible value of $floor(Ax/B) - A × floor(x/B)$ for a non-negative integer $x$ not greater than $N$. Here $floor(t)$ denotes the greatest integer not greater than the real number $t$. ## Constraints * $1 ≤ A ≤ 10^{6}$ * $1 ≤ B ≤ 10^{12}$ * $1 ≤ N ≤ 10^{12}$ * All values in input are integers. ## Input Input is given from Standard Input in the following format: $A$ $B$ $N$ [samples]
Samples
Input #1
5 7 4
Output #1
2

When $x=3$, $floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2$. This is the maximum value possible.
Input #2
11 10 9
Output #2
9
API Response (JSON)
{
  "problem": {
    "name": "Floor Function",
    "description": {
      "content": "Given are integers $A$, $B$, and $N$. Find the maximum possible value of $floor(Ax/B) - A × floor(x/B)$ for a non-negative integer $x$ not greater than $N$. Here $floor(t)$ denotes the greatest intege",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc165_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Given are integers $A$, $B$, and $N$.\nFind the maximum possible value of $floor(Ax/B) - A × floor(x/B)$ for a non-negative integer $x$ not greater than $N$.\nHere $floor(t)$ denotes the greatest intege...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments