Problem:
Score : 400 points

Problem Statement

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

Output

Print the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.

Sample Input 1

5 7 4

Sample 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.

Sample Input 2

11 10 9

Sample Output 2

9

Solution in JavaScript (Node.js 12.16.1) (judge verdict: Wrong Answer)

const Main = (input) => {
    // array = input.split('\n')
    // ABN = array.shift().split(' ').map(item => parseInt(item))
    ABN = input.split(' ').map(item => parseInt(item))
    // array.pop()
    // console.log(array)
    // arrayInt = array.map(item => item.split(' ').map(value => parseInt(value)))
    // console.log(arrayInt)
    // arrayInt = array.map(item => parseInt(item))
    console.log(F(ABN[0], ABN[1], ABN[2]))
}

const F = (A, B, N) => {
    max = 0
    count = 0
    count0 = 0
    for (x = 0; x <= N; x++) {
        result = Math.floor(A * x / B) - A * Math.floor(x / B)
        if (result == 0) {
            count0++
        }
        if (count0 > 100) {
            break
        }
        // console.log(x, result, max)
        if (result > max) {
            max = result
            count = x
        }
    }
    return max
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));