Menu Close

Compute the maximum possible value of the given equation

Ragu has given 3 integers A, B, and N to Dhamo.
Now Ragu asked Dhamo to calculate 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’.
Can you help Dhamo ?

Input:
Input is given in the following format:
A B N

Output:
Print the output to calculate the maximum possible value of 
floor(Ax/B)-A × floor(x/B) 
for a non-negative integer 'x' not greater than 'N'.
#include <stdio.h>
#define min(a,b) ((a)>(b)?(b):(a))
int main()
{
  long a, b, n, y;
  scanf("%ld %ld %ld",&a,&b,&n);
  y=(double)a*min(b-1, n);
  y=y/(double)b;
  printf("%ld",y);
return 0;
}

INPUT_1:
11 8 14

OUTPUT:
9


INPUT_2:
28 49 36

OUTPUT:
20


ILLUSTRATION

eXeCUTED USING GCC TERMINAL LINUX

Morae Q!