Problem 3007 --fraction

3007: fraction

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $1$ 正确数量 $1$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
Many problems require printing the probability of something. Moreover, it is common that if the answer is abab, you should output a×b−1(modp)a×b−1(modp) (pp is a prime number). In these problems, you cannot know the exact value of the probability. It's so confusing!!! Now, we want to reverse engineer the exact probability from such calculated output value xx. We do so by guessing the probability is the one with the minimum bb such that a×b−1=x(modp)a×b−1=x(modp). Now we invite you to solve this problem with us! 

You are given two positive integers pp and xx, where pp is a prime number. 

Please find the smallest positive integer bb such that there exist some positive integer aa satisfying a<ba<b and a≡bx(modp)a≡bx(modp).
The first line contains an integer TT indicating there are TT tests. Each test consists of a single line containing two integers: p,xp,x

1≤T≤2×1051≤T≤2×105 

3≤p≤10153≤p≤1015 

pp is a prime 

1<x<p
For each test, output a line containing a string represents the fraction abab using the format "a/b" (without quotes).
3
11 7
998244353 554580197
998244353 998244352
2/5
8/9
499122176/499122177

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

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$189 $ms] 淡意的温柔 590708 2020-06-05 08:38:15
内存最少[$2080 $KB] 淡意的温柔 590708 2020-06-05 08:38:15
第一AC 淡意的温柔 590708 2020-06-05 08:38:15
第一挑战 淡意的温柔 590708 2020-06-05 08:38:15

赛题来源/所属竞赛 2019 Multi-University Training Contest 5 N/A

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