Problem 2966 --Meteor

2966: Meteor

"
Time Limit $8$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $2$ 正确数量 $2$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
Though time passes, there is always someone we will never forget. 
"The probability of being hit by a meteor is one in a billion, but it is much more miraculous, to meet you in my life." said Tom to Jerry with affection. 
"One in a billion? I may not agree with you." answered Jerry proudly, "Let's do the math." 
... 
Thinking of the days they have happily spent together, Tom can't help bursting into tears. Though Jerry has been gone for a long time, Tom still misses him every day. He remembers it was a sunny afternoon when Jerry and him were lying in the yard, working on the probability of a man being hit by a meteor. 
Unlike Jerry, he was always slow. Jerry got the answer soon, but Tom was stuck as usual. In the end, Tom lost patience and asked Jerry to tell him the answer. 
"I can't be so straightforward," snickered Jerry, "the only thing I will tell you is that the answer is pqpq , where p,q≤n,gcd(p,q)=1p,q≤n,gcd(p,q)=1 ." 
"Is it 1n1n ?" 
"Is it 1n−11n−1 ?" 
... 
If answered "No" , he would try the minimum larger number that satisfies the requirement. 
Tom only remembered nn given by Jerry, and kk, the times that he tried, but forgot what matters the most: Jerry's answer. Now, he wants you to help him find it.
The first line contains an integer T(T≤102)T(T≤102), the number of test cases. 
The next TT lines, each line contains two numbers, n,k(2≤n≤106)n,k(2≤n≤106), indicating a query. 
The answer is guaranteed to be in (0,1](0,1].
TT lines, each line contains a fraction in term of p/q ,where gcd(p,q)=1gcd(p,q)=1.
5
4 6
5 1
9 9
3 4
7 11
1/1
1/5
1/3
1/1
3/5
g++ compiler on HDOJ supports __int128.

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

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$2400 $ms] 刘成健 460866 2019-09-04 10:36:40
内存最少[$14872 $KB] 刘成健 460866 2019-09-04 10:36:40
第一AC 刘成健 460866 2019-09-04 10:36:40
第一挑战 刘成健 460866 2019-09-04 10:36:40

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

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