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 C++ (GCC 9.2.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());


ll a,b,n;



int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> a >> b >> n;
    ll sta = n%b;
    ll kojen = n;
    if(sta != b-1){
        kojen = (n - n%b) - 1;
    }
    ll res = 0;
    if(kojen >= 0) res = (a*kojen) / b  - a*((kojen)/b);
    //cout << res << endl;
    fb(i,n,n-100){
        if(i < 0)break;

        res = max(res, (a*i)/b - a*((i)/b));
    }
    if(b-1 <= n)res = max(res, (a*(b-1))/b - a*((b-1)/b));
    ff(i,0,100){
        if(i > n)break;
        res = max(res, (a*i)/b - a*((i)/b));
    }
    ll last = -1;
    if(a == 1 || b == 1){
        cout << res << endl;
        return 0;
    }
    cout << res << endl;
    return 0;
}