Mathforces
Practice
5 (2 votes)
Problem
42% Success 106 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code
You are given two integers \(A\) and \(B\). Print the sum of numbers that cannot be formed using any combination of \(A\) and \(B\) . If the sum is infinite print \(-1\). Since the answer can be large, print the sum modulo \(10^9+9\).
A combination of \(A\) and \(B\) can be represented as an integer C that is denoted as \(x*A+y*B\) where \(x\) and \(y\) are whole numbers.
INPUT FORMAT:
The first line contains an integer \(T\), denoting the number of test cases. Each of the next \(T\) lines contains two space separated integers \(A\) and \(B\).
OUTPUT FORMAT:
For each test case print the answer in a new line.
CONSTRAINTS:
\(1\leq T\leq10^5\)
\(1\leq A,B\leq10^9\)
\(B=A+1\)
Submissions
Please login to view your submissions
Similar Problems
Points:30
Tags:
MediumModular arithmeticNumber Theory
Points:30
1 votes
Points:30
8 votes
Tags:
MathNumber TheoryModulus ArithmeticC++
Editorial
No editorial available for this problem.