9406. Professor and batteries

 

There are some packs of batteries on the Professor’s table. There are a batteries in each pack. When the Professor took b batteries from each pack, only c batteries remained on the table.

How many packs of batteries were on the table?

 

Input. Three positive integers a, b, c.

 

Output. Print the number of packs with batteries on the table.

 

Samole input

Sample output

6 3 15

5

 

 

SOLUTION

mathematics

 

Algorithm analysis

Let there be x packages with batteries on the table. After the professor took b batteries from each package, (ab) * x batteries were left on the table. This number is equal to c. Therefore, x = c / (ab).

 

Algorithm realization

Read the input data. Compute and print the answer.

 

scanf("%d %d %d", &a, &b, &c);

res = c / (a - b);

printf("%d\n", res);

 

Java realization

 

import java.util.*;

 

public class Main

{

  public static void main(String[] args)

  {

    Scanner con = new Scanner(System.in);

    int a = con.nextInt();

    int b = con.nextInt();

    int c = con.nextInt();

  

    int res = c / (a - b);

   

    System.out.println(res);

    con.close();

  }

}

 

Python realization

 

a, b, c = map(int,input().split())

res = c // (a - b)

print(res)