A. Johnny and Ancient Computer1000 / 思维

Posted 幽殇默

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了A. Johnny and Ancient Computer1000 / 思维相关的知识,希望对你有一定的参考价值。


https://codeforces.com/problemset/problem/1362/A
默认a<b 如果a>b说明a要除等价于b要乘,所以我们统一的让a<b 都用a来乘。

#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
int main(void)
{
    int t; cin>>t;
    while(t--)
    {
        LL a,b; cin>>a>>b;
        LL cnt=0;
        if(a>=b) swap(a,b); //默认a<b
        while(a<b) a*=2,cnt++;
        if(a!=b) puts("-1");
        else printf("%lld\\n",cnt/3+(cnt%3)/2+(cnt%3)%2);// 8 4 2
    }
    return 0;
}

以上是关于A. Johnny and Ancient Computer1000 / 思维的主要内容,如果未能解决你的问题,请参考以下文章

E. Johnny and Grandmaster

Codeforces 611D.New Year and Ancient Prophecy (dp + lcp)

Ancient Rome and Greece

Trade and the Ancient Middle East

Codeforces Round #647 (Div. 2) B. Johnny and His Hobbies(枚举)

Codeforces Round #647 (Div. 2) B. Johnny and His Hobbies(枚举)