![]() | ||||
Online Judge | Problem Set | Authors | Online Contests | User |
---|---|---|---|---|
Web Board Home Page F.A.Qs Announcement | Current Contest Past Contests Scheduled Contests Award Contest |
Strange Way to Express Integers
Description Choose k different positive integers a1, a2, ¡, ak. For some non-negative m, divide it by every ai (1 ¡Ü i ¡Ü k) to find the remainder ri. If a1, a2, ¡, ak are properly chosen, m can be determined, then the pairs (ai, ri) can be used to express m. ¡°It is easy to calculate the pairs from m, ¡± said Elina. ¡°But how can I find m from the pairs?¡± Since Elina is new to programming, this problem is too difficult for her. Can you help her? Input The input contains multiple test cases. Each test cases consists of some lines. Output Output the non-negative integer m
on a separate line for each test case. If there are multiple possible
values, output the smallest one. If there are no possible values,
output -1. Sample Input Sample Output Hint All integers in the input and the output are non-negative and can be represented by 64-bit integral types. Source |
[Submit] [Go Back] [Status] [Discuss]
All Copyright Reserved 2003-2005 Ying Fuchen,Xu Pengcheng
Any problem, Please Contact Administrator