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: Time Limit Exceeded)

#include "bits/stdc++.h"

using namespace std;
#define rep(i, n) for (int64_t i = 0; i < n; i++)

const double PI = 3.14159265358979323846;

int main()
{
	/*int64_t n, m, q, max_pt = 0, count_c = 0, counter = 0;
	
	cin >> n >> m >> q;
	auto b = vector<vector<int64_t>>(q, vector<int64_t>(4, 0));
	for (int64_t i = 0; i < q; i++)
	{
		cin >> b[i][0] >> b[i][1] >> b[i][2] >> b[i][3];
	}
	auto a = vector<int64_t>(n, 1);

	for (int64_t i = 0; i < n; i++)
	{
		counter += pow(m, n);
		cout << a[i];
	}
	puts("");
	
	while(true)
	{
		int64_t now_pt = 0;
		for (int64_t i = 0; i < q; i++)
		{
			if (a[b[i][1] - 1] - a[b[i][0] - 1] == b[i][2])
			{
				now_pt += b[i][3];
			}
		}
		max_pt = max(now_pt, max_pt);
		count_c = counter;
		for (int64_t i = 0; i < n; i++)
		{
			a[n - i - 1] = count_c % (int64_t)pow(m, i);
		}
		counter++;
		bool temp = true;
		for (int i = 0; i < n; i++)
		{
			cout << a[i];
			if (a[i] == m)
			{
				temp = true;
			}
			else
			{
				temp = false;
				break;
			}
		}
		if (temp)
		{
			break;
		}
		puts("");*/
	//}

	int64_t a, b, c, max_s = 0, tmep;

	cin >> a >> b >> c;
	
	for (int i = 1; i <= c; i++)
	{
		tmep = floor((a * i) / b) - (a * floor(i / b));
		if (max_s < tmep)
		{
			max_s = tmep;
		}
	}

	cout << max_s << endl;

	return 0;
	
}