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 <functional>  
#include <algorithm>  
#include <iostream>  
#include <fstream>  
#include <sstream>  
#include <iomanip>  
#include <numeric>  
#include <cstring>  
#include <cassert>  
#include <cstdio>  
#include <string>  
#include <vector>  
#include <bitset>  
#include <queue>  
#include <stack>  
#include <cmath>  
#include <ctime>  
#include <list>  
#include <set>  
#include <map>  

using namespace std;

#define PB push_back  
#define MP(A, B) make_pair(A, B)  
#define fi first  
#define se second  

#define gcd(a,b) __gcd(a,b)
#define pi acos(-1.0)
#define pii pair<int,int>
#define ll long long  
#define MAX 1000005  
#define MOD 1000000007  
#define INF 0x3f3f3f3f  
#define EXP 1e-8  
#define lowbit(x) (x&-x)  
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

int main()
{
    ll a, b, n, ans;
    cin >> a >> b >> n;
    // for (int i = 0; i < 5*b; ++i) {
    //     cout << floor((double)a*(i)/b) - a*floor((double)(i)/b) << ' ' << i << endl;
    // }
    if (b-1 <= n) {
        for (int i = 0; i <= a; ++i) {
            ll tans =(ll)floor((double)a*(i)/b) - (ll)a*floor((double)(i)/b);
            ans = max(ans, tans); 
        }
        ll tans = floor((double)a*(b-1)/b) - a*floor((double)(b-1)/b);
            ans = max(ans, tans); 
        cout << ans;
        return 0;}
    if (n <= b) {
        ans = floor((double)a*(n)/b) - a*floor((double)(n)/b);
        ll tans = -1;
        if (n-1>=0) tans = floor((double)a*(n-1)/b) - a*floor((double)(n-1)/b);
        ans = min(ans, tans);
        // if (a < b) {
        //     int x = (b/a);
        //     int tans = floor((double)a*(n)/b) - a*floor((double)(n)/b);
        // }
    }
    cout << ans << endl;
    return 0;
}