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# (.NET Core 3.1.201) (judge verdict: Wrong Answer)

using System;
					
public class Program
{
	public static void Main()
	{
		string[] str = Console.ReadLine().Split(' ');
		ulong A = ulong.Parse(str[0]); 
      	ulong B = ulong.Parse(str[1]); 
		ulong N = ulong.Parse(str[2]); 
		double tmp1;
		double anser=0.0;
		
		Sol mySol =new Sol();
		for(ulong i=N-1; i<=N; i++){
			tmp1 = mySol.Solve(A,B,i);
			
			if(anser<tmp1){
				anser=tmp1;
			}
		}
		Console.WriteLine(anser);
		/*
		string[] str = Console.ReadLine().Split(' ');
		int A = int.Parse(str[0]); 
      	int B = int.Parse(str[1]); 
		double num = A / K;
		double ans;
		int amari = A%K;
		
		ulong en = 100;
		ulong cnt=0;
		
		for(int i=0; en < X; i++){
			en = en + en/100;
			cnt++;
		}
		
		Console.WriteLine(cnt);
		*/
	}
}

public class Sol
{
	public double Solve(ulong A, ulong B, ulong x)
	{
		double ans;
		double tmp1 = (A*x)/B;
		double tmp2 = x/B;
		
		tmp1 = Math.Truncate(tmp1);
		tmp2 = Math.Truncate(tmp2);
		
		ans = tmp1 - (A*tmp2);
		
		return ans;
	}
}