Problem 3778 --Pass!

3778: Pass!

"
Time Limit $1$ 秒/Second(s) Memory Limit $128$ 兆字节/Megabyte(s)
提交总数 $0$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
There are n players passing ball on the football field.

Initially, the first player has the ball. Then each second, the player with ball should pass the ball to any other player.

Alice wonders how many way to pass the ball, such that after t seconds, the ball will turn back to the first player. So she asks Bob for help.

Now, Bob solved the question and found that the answer modulo 998244353 is x. But he forgot the exact number of t. So he ask you for help, to find the smallest non-negative integer t, such that the answer of Alice's question modulo 998244353 will be x.
The first line contains an integer T(1≤T≤100)representing the number of test cases.

For each test case, there are two integers n,x(2≤n≤106,0≤x<998244353)in one line.
For each test case, output a single line containing one integer indicates the smallest t. If such t do not exist, output −1 instead.
5
11 1
11 0
11 10
11 76805204
11 2
0
1
2
233333
-1

推荐代码 查看3778 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战

赛题来源/所属竞赛 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛