A. Valid Integer
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Time Limit: 0.5 s
Memory Limit: 256.0 MB
Description
You are given two positive integers x and y.
Your task is to find any positive integer
ksuch that:- 1 ≤ k ≤ 100
- k is not divisible by x
- k is not divisible by y
If no such integer exists, print -1.
Input
The first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases.
Each of the next t lines contains two integers x and y (1 ≤ x, y ≤ 100).
Output
For each test case, print one integer:
Any integer k (1 ≤ k ≤ 100) that is not divisible by both x and y
Print
-1if no such integer exists
Sample
| Input | Output |
|---|---|
|
|
- First test case : 17 is a Valid Answer.
- 17 % 2 ≠ 0 → not divisible by 2
- 17 % 4 ≠ 0 → not divisible by 4
- 17 lies in the range 1 to 100
So, 17 satisfies all conditions and is a valid answer.
Note: There are also other valid answers. (ex. 19,13,23 etc).
Happy New Year 2026
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 7
- Start at
- 2026-01-06 14:30
- End at
- 2026-01-06 17:15
- Duration
- 2.8 hour(s)
- Host
- Partic.
- 108