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;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO.Pipes;
using System.Runtime;

namespace Csharponly
{
    class Program
    {
        static public void Main()
        {
           	long[] ABN = Arraylong();
            long b;
			if(ABN[2] > ABN[1])
			{
				b = ABN[1]-1;
			}
            else{
            	b = ABN[2];
            }
            
            long c = ABN[0]/ABN[1];
            long d = ABN[0]%ABN[1];
            
            string bc = Kakeru(b.ToString(), c.ToString());
            string bd = Kakeru(b.ToString(), d.ToString());
            string ans = Tasu(bc, bd);
			Console.WriteLine(ans);
          
        	}

      static string Kakeru(string a1, string b1)
        {
            int anum = a1.Length;
            int bnum = b1.Length;
            int[] a = Array(a1);
            int[] b = Array(b1);
 
            int[] kakeruans = new int[anum + bnum];
            for(int i = 0; i < anum; i++)
            {
                for(int j = 0; j < bnum; j++)
                {
                    kakeruans[i + j] += a[i] * b[j];
                }
            }
            for(int i = 0; i < kakeruans.Length; i++)
            {
                if(kakeruans[i] >= 10)
                {
                    kakeruans[i + 1] += kakeruans[i] / 10;
                    kakeruans[i] = kakeruans[i] % 10;
                }
            }
            string kakerustring = "";
            for (int i = 0; i < kakeruans.Length - 1; i++)
            {
                kakerustring = kakeruans[i].ToString() + kakerustring;
            }
            if (kakeruans[kakeruans.Length - 1] != 0)
            {
                kakerustring = kakeruans[kakeruans.Length - 1].ToString() + kakerustring;
            }
 
            return kakerustring;
        }
 
        static string Tasu(string a1, string b1)
        {
            int anum = a1.Length;
            int bnum = b1.Length;
            int[] a = Array(a1);
            int[] b = Array(b1);
 
            string tasustring = "";
            if (anum < bnum)
            {
                int[] tasuans = new int[bnum + 1];
                for (int i = 0; i < anum; i++)
                {
                    tasuans[i] = a[i] + b[i];
                }
                for(int i = anum; i < bnum; i++)
                {
                    tasuans[i] = b[i];
                }
                for(int i = 0; i < tasuans.Length; i++)
                {
                    if(tasuans[i] >= 10)
                    {
                        tasuans[i] -= 10;
                        tasuans[i + 1]++; 
                    }
                }
                for (int i = 0; i < tasuans.Length - 1; i++)
                {
                    tasustring = tasuans[i].ToString() + tasustring;
                }
                if(tasuans[tasuans.Length - 1] != 0)
                {
                    tasustring = tasuans[tasuans.Length - 1].ToString() + tasustring;
                }
            }
            else
            {
                int[] tasuans = new int[anum + 1];
                for (int i = 0; i < bnum; i++)
                {
                    tasuans[i] = a[i] + b[i];
                }
                for (int i = bnum; i < anum; i++)
                {
                    tasuans[i] = a[i];
                }
                for (int i = 0; i < tasuans.Length; i++)
                {
                    if (tasuans[i] >= 10)
                    {
                        tasuans[i] -= 10;
                        tasuans[i + 1]++;
                    }
                }
                for (int i = 0; i < tasuans.Length - 1 ; i++)
                {
                    tasustring = tasuans[i].ToString() + tasustring;
                }
                if (tasuans[tasuans.Length - 1] != 0)
                {
                    tasustring = tasuans[tasuans.Length - 1].ToString() + tasustring;
                }               
            }
            return tasustring;
        }
 
        static int[] Array(string A)
        {
            int[] a = new int[A.Length];
            string num;
            for (int i = 0; i < A.Length; i++)
            {
                num = A.Substring(i, 1);
                a[A.Length - i - 1] = int.Parse(num);
            }
 
            return a;
        }
　　　　//一つの文字列を受け渡す
        static string Onestring()
        {
            return Console.ReadLine();
        }

        //複数の文字列を配列で受け渡す
        //文字列と文字列の間は" "で区切る
        static string[] Arraystring()
        {
            return Console.ReadLine().Split(' ');
        }

        //一つの数字を受け渡す
        static int Oneint()
        {
            return int.Parse(Console.ReadLine());
        }
        static long Onelong()
        {
            return long.Parse(Console.ReadLine());
        }

        //複数の数字を配列で受け渡す
        //数字と数字の間は" "で区切る
        static int[] Arrayint()
        {
            String[] input_line = Console.ReadLine().Split(' ');
            int[] input_num = new int[input_line.Length];
            for (int i = 0; i < input_line.Length; i++)
            {
                input_num[i] = int.Parse(input_line[i]);
            }
            return input_num;
        }
        static long[] Arraylong()
        {
            String[] input_line = Console.ReadLine().Split(' ');
            long[] input_num = new long[input_line.Length];
            for (int i = 0; i < input_line.Length; i++)
            {
                input_num[i] = long.Parse(input_line[i]);
            }
            return input_num;
        }
    }
}