Rabbit Lunch
Time limit8sMemory limit512 MB
Given counts of M carrot kinds and N kiwi kinds generated by recurrences, find the maximum number of distinct (carrot kind, kiwi kind) pairs a rabbit can take, one carrot and one kiwi each.
- Level
Medium7 of 10
- Topics
- Greedy, Sorting, Math, Implementation
- Solved
- No attempts yet
Problem
A rabbit eats one carrot and one kiwi for lunch. Rabbits are very distinctive, so there must not be two different rabbits that eat the same kind of carrot and the same kind of kiwi.
There are kinds of carrots. There are carrots of the -th kind. There are kinds of kiwis. There are kiwis of the -th kind. Find the maximum number of rabbits that can eat lunch.
Generate and using the following recurrences.
- mod
- mod
Input
The input is given in the following format:
Output
Print one integer on a single line: the maximum number of rabbits that can eat lunch.
Constraints
- will be between 1 and 2,500,000, inclusive.
- will be between 1 and 2,500,000, inclusive.
- and will be between 0 and , inclusive.
- and will be between 0 and , inclusive.