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>
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define MOD 1000000007
#define MAXN 1000005

using namespace std;

long double cal(ld A,ld B,long double N,long double x){
    return (floor(A*x/B) - (A*floor(x/B)));

}

long double findval(long double A,long double B,long double N){
    ll low=cal(A,B,N,0),high=cal(A,B,N,N),l=0,h=N,m,i=0,mid;
    if(high<low) swap(high,low);
    while(low<high){
        m=(h+l)/2;
        mid=cal(A,B,N,m);
        if(mid<high){
            low=mid;
            l=m+1;
        }
        else if(mid<low){
            high=mid;
            h=m;
        }
        else break;



    }
    return mid;


}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    ll T=1;
    //cin>>T;
    while(T--)
    {
        long double A,B,N;
        cin>>A>>B>>N;
        cout<<findval(A,B,N);











    }



    return 0;
}