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 <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;



ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll A, B;
int score(ll x) {
	return (A * x / B) - A * (x / B);
}

void BS(ll a, ll b) {
	if (a +1== b  || a == b) {
		ll ans = max(score(a), score(b));
		cout << ans;
		return;
	}
	ll c = (a + b) / 2;
	ll p = score(a);
	ll q = score(b);
	ll r = score(c);
//	cout << p << " " << r << " " << q << endl;
	if (p > q) {
		BS(a, c);
	}
	else if (p < q) {
		BS(c, b);
	}
	else {
		BS(a, (b+c)/2);
	}
}


int main() {
	string S;
	int i, j, k;
	//ll N, M, K;
	//int N, M, K;
	
	ll N, x;
	cin >> A >> B >> N;
	if (A == 1 || B == 1) {
		cout << 0;
		return 0;
	}
	BS(0, N);


	return 0;

}