Topic description:
A certain company department needs to send employees to work on projects abroad. Now, the country code-named x and the country code-named y need cntx and cnty employees respectively. Each employee in the department has an employee number (1,2,3...), and the employee numbers are consecutive, starting from 1.
Rules for ministers dispatching employees:
- Rule 1. Select employees from [1,k] to dispatch
- Rule 2: Employees whose number is a multiple of x cannot go to country x, and employees whose number is a multiple of y cannot go to country y.
Problem:
Find the smallest k so that employees numbered in [1,k] can be assigned to country x and country y, and satisfy the requirements of country x and country y Requirements
Enter description:
Four integers x, y, cntx, cnty. (2<=x<y<=30000; x and y must be prime numbers; 1<=cntx,cnty<10^9; cntx+cnty<=10^9)
Output description:
The smallest k that satisfies the condition.
Example 1
enter:
2 3 3 1
Output:
5
illustrate:
Enter a description:
2 - represents country code 2
3 - represents country code 3
3 - means country 2 requires 3 people
1 - means country 3 requires 1 person