ABBYY Cup 2.0 - Easy

Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
177 ABBYY Cup 2.0 - Easy FINISHED False 14400 441388823 April 21, 2012, 2 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 710 ) E1 Space Voyage PROGRAMMING binary search 1700

The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i a i is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and b i is the number of citizens on the planet. The Smart Beaver is going to bring some presents from ABBYY to the planets he will be visiting. The presents are packed in suitcases, x presents in each. The Beaver will take to the ship exactly a 1 + ... + a n suitcases. As the Beaver lands on the i -th planet, he takes a i suitcases and goes out. On the first day on the planet the Beaver takes a walk and gets to know the citizens. On the second and all subsequent days the Beaver gives presents to the citizens — each of the b i citizens gets one present per day. The Beaver leaves the planet in the evening of the day when the number of presents left is strictly less than the number of citizens (i.e. as soon as he won't be able to give away the proper number of presents the next day). He leaves the remaining presents at the hotel. The Beaver is going to spend exactly c days traveling. The time spent on flights between the planets is considered to be zero. In how many ways can one choose the positive integer x so that the planned voyage will take exactly c days? The first input line contains space-separated integers n and c — the number of planets that the Beaver is going to visit and the number of days he is going to spend traveling, correspondingly. The next n lines contain pairs of space-separated integers a i , b i ( 1 ≤ i ≤ n ) — the number of suitcases he can bring to the i -th planet and the number of citizens of the i -th planet, correspondingly. The input limitations for getting 30 points are: 1 ≤ n ≤ 100 1 ≤ a i ≤ 100 1 ≤ b i ≤ 100 1 ≤ c ≤ 100 The input limitations for getting 100 points are: 1 ≤ n ≤ 10 4 0 ≤ a i ≤ 10 9 1 ≤ b i ≤ 10 9 1 ≤ c ≤ 10 9 Due to possible overflow, it is recommended to use the 64-bit arithmetic.

Tutorials

Submissions

No solutions yet.