Codeforces Round #647 (Div. 2) - Thanks, Algo Muse! 参与排名人数12044
[codeforces 1362A] Johnny and Ancient Computer 倍数关系用2的幂次统计
总目录详见https://blog.csdn.net/mrcrack/article/details/103564004
在线测评地址https://codeforces.com/contest/1362/problem/A
Problem | Lang | Verdict | Time | Memory |
---|---|---|---|---|
A - Johnny and Ancient Computer | GNU C++17 | Accepted | 31 ms | 0 KB |
样例分析如下
10 5
10=5×2^1
2的幂次是1
1<=3
输出1
11 44
44=11×2^2
2的幂次是2
2<=3
输出1
17 21
21无法用17乘2的幂次来表示
输出-1
1 1
1==1
输出0
96 3
96=3×2^5
2的幂次是5
5=3+2
输出2
2 128
128=2*2^6
2的幂次是6
6=3+3
输出2
1001 1100611139403776
1100611139403776=1001*2^40
2的幂次是40
40=3*13+1
输出14
1000000000000000000 1000000000000000000
1000000000000000000==1000000000000000000
输出0
7 1
7无法用1乘2的幂次来表示
输出-1
10 8
10无法用8乘2的幂次来表示
输出-1
AC代码如下
#include
#define LL long long
int main(){
int t,cnt,flag;
LL a,b,c;
scanf("%d",&t);
while(t--){
scanf("%lld%lld",&a,&b);
if(a==b){printf("0\n");continue;}
if(a