#P1495. 【模板】中国剩余定理(CRT)/ 曹冲养猪
【模板】中国剩余定理(CRT)/ 曹冲养猪
Description
After Cao Chong solved the elephant problem, Cao Cao wanted his son to take on some real work, so he sent him to manage a pig farm in the Central Plains. Cao Chong was unhappy and worked carelessly. One day, Cao Cao wanted to know the number of sows, so Cao Chong decided to play a trick on him. For example, suppose there are sows. If pens are built, then sow has nowhere to go. If pens are built, there is still sow with no place to go. If pens are built, there are sows left without a place. As Cao Cao’s personal secretary, you must report the exact number of sows. What should you do?
Input Format
The first line contains an integer — the number of times pens are built. The next lines each contain two integers , meaning that when pens are built, there are sows without a place to go. You may assume are pairwise coprime.
Output Format
Output a single positive integer: the minimum possible number of sows that Cao Chong raises.
3
3 1
5 1
7 2
16
Hint
,,
Translated by ChatGPT 5
京公网安备 11011102002149号