TopcoderArchiveVisit Topcoder
SRM12 Dec 2001
SRM 49

MultiSum

Problem statement, definition, constraints, and public examples.

Problem Statement

PROBLEM STATEMENT

On her first day of math class, Amy was given the following problem:

Find the number of all positive integers not greater than B, that can be
represented as a sum of a positive multiple of X and a positive multiple of Y.
B, X and Y are given positive integer constants.

After reading through it, she immediately formed the system:

0 < T <= B
L1 * X + L2 * Y = T  (of course * takes precedence, by order of operations)

She then asks herself how many integer solutions for T does the system have? 
 
Write a class MultiSum with a method getCount, which takes 3 ints (B, X and Y)
as arguments and returns the number of positive integers that are not greater
than B and are representable as a sum of a positive multiple of X and a
positive multiple of Y.

DEFINITION

Class name:   MultiSum
Method name:  getCount
Parameters:   int, int, int
Returns:      int

Method signature:   (be sure your method is public):
  int getCount(int B, int X, int Y); 

TopCoder will ensure that:
* 1 < X < B
* 1 < Y < B
* 2 < B < 1001

EXAMPLES

Let B = 20, X = 3, Y = 4. The numbers that satisfy our condition are 7, 10,
11, 13, 14, 15, 16, 17, 18, 19, 20. So your method should return 11.

B = 50, X = 7, Y = 13 -> Result = 9
B = 100, X = 10, Y = 10 -> Result = 9
B = 1000, X = 30, Y = 45 -> Result = 61

Definition

Class:
MultiSum
Method:
getCount
Parameters:
int, int, int
Returns:
int
Method signature:
int getCount(int param0, int param1, int param2)
(be sure your method is public)

Constraints

    Examples

      No public sample cases were explicitly marked for this problem in the original data.

      Back to all problems