fractionTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 467 Accepted Submission(s): 249 Problem Description Many problems require printing the probability of something. Moreover, it is common that if the answer is ab , you should output a×b−1(modp) (p 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 x . We do so by guessing the probability is the one with the minimum b such that a×b−1=x(modp) . Now we invite you to solve this problem with us!
Input The first line contains an integer T indicating there are T tests. Each test consists of a single line containing two integers: p,x .
Output For each test, output a line containing a string represents the fraction ab using the format "a/b" (without quotes).
Sample Input 3 11 7 998244353 554580197 998244353 998244352
Sample Output 2/5 8/9 499122176/499122177
现在要求两个分数间分母最小的分数
如果
如果没有的话 两个分数
类似exgcd
继续寻找答案 最后 再恢复即可
参考
函数gao(a,b,c,d,x,y)是在求解
最小的 x y 本题是求
|
HDU 6624 fraction 辗转相除法
最新推荐文章于 2019-09-27 15:30:48 发布