Problem 3014 --discrete logarithm problem

3014: discrete logarithm problem

"
Time Limit $2$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $1$ 正确数量 $1$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
You are given three integers p,a,bp,a,b, where pp is a prime number and p−1p−1 only has prime factors 22 and/or 33. Please find the minimum positive integer xx such that ax≡b(modp)ax≡b(modp).
The first line contains an integer TT indicating there are TT tests. Each test consists of a single line containing three integers: p,a,bp,a,b

T≤200T≤200 

65537≤p≤101865537≤p≤1018 

* the prime factors of p−1p−1 can only be 22 or 33 

2≤a,b≤p−1
For each test, output a line containing an integer xx, representing the minimum positive value such that ax≡b(modp)ax≡b(modp). If there didn't exist any such number xx, please output −1−1.
6
65537 2 3
65537 2 4
65537 3 4
65537 4 4
65537 5 4
666334875701477377 2 3
-1
2
45056
1
36864
1957714645490451

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

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

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

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