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: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
	class Program
	{
/*		public class Temp
		{
			public int a { get; set; }
			public int b { get; set; }
			public int c { get; set; }
			public int d { get; set; }
		}

		// Aは長さNの整数列
		var N = valueList[0];
		// 1 と Mの間の数字で構成
		var M = valueList[1];
		var Q = valueList[2];

		var tempList = new List<Temp>();

			for (int i = 0; i<Q; i++)
			{
				var inputValueList = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
		tempList.Add(new Temp() { a = inputValueList[0], b = inputValueList[1],c = inputValueList[2],d = inputValueList[3]});
			}

*/

	static void Main(string[] args)
		{
			var valueList = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

			var A = valueList[0];
			var B = valueList[1];
			var N = valueList[2];

			long answer = 0;

			if(B > N)
			{
				var first = (A * N / B);
				var last = 5 * (N / B);
				answer = first - last;
			}
			else
			{
				var first = (A * (B - 1) / B);
				var last = 5 * ((B - 1) / B);
				answer = first - last;

			}

/*			for (long i = 1; i <= N; i++)
			{
				var first =  (A * i / B);
				var last = 5 * (i / B);

				var answer = first - last;

				if(max < answer)
				{
					max = answer;
				}
			}
*/
			Console.WriteLine(answer);
		}
	}
}