BestCoder Round #60 HDU5505 GT and numbers

来源:互联网 发布:唐诗逸和张傲月 知乎 编辑:程序博客网 时间:2024/05/18 03:46


GT and numbers

                                            Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
                                                                           Total Submission(s): 368    Accepted Submission(s): 103


Problem Description
You are given two numbers N and M.

Every step you can get a new N in the way that multiply N by a factor of N.

Work out how many steps can N be equal to M at least.

If N can't be to M forever,print 1.
 

Input
In the first line there is a number T.T is the test number.

In the next T lines there are two numbers N and M.

T10001N1000000,1M263.

Be careful to the range of M.

You'd better print the enter in the last line when you hack others.

You'd better not print space in the last of each line when you hack others.
 

Output
For each test case,output an answer.
 

Sample Input
31 11 22 4
 

Sample Output
0-11
 

Source
BestCoder Round #60


出题人:

如果AA大于BB那么显然无解。考虑把ABB分解质因数。

BB存在AA没有的质因数也显然无解。对于某一个AA的质因数的次数。

A

为了加速接近BB,它一定是每次翻倍,最后一次的时候把剩下的加上。

那么答案就是最小的kk使得2^{k}*A_{num} \geq B_{num}2kAnumBnum

最后把每个质因数的答案max起来即可。感觉本场比赛没有trick(雾~),

我就打算加入一个很经典的trick:B可以刚好等于2^{63}263

B这样就要开unsigned long long。同时我还在题目里特别提醒了

“注意M的范围”可惜仍然有很多选手没有注意。

这里我表示歉意,也希望你们以后可以更加仔细一点。








0 0