#P10663. BZOJ4833 最小公倍佩尔数
BZOJ4833 最小公倍佩尔数
Background
This problem comes from the BZOJ April 2017 monthly contest.
Problem Description
Let , where are both integers. It is clear that . Let .
Given two positive integers , where is a prime number, and it is guaranteed that are all non-zero modulo , compute the value of modulo .
Input Format
The first line contains a positive integer , meaning there are test cases.
The following lines are the testdata. Each test case occupies one line and contains two positive integers and .
Output Format
For each test case, output one line containing one non-negative integer, which is the answer for this test case.
5
1 233
2 233
3 233
4 233
5 233
1
5
35
42
121
Hint
Constraints: for of the testdata, , , , .
Translated by ChatGPT 5