Codeforces 871div4 D
// compile: g++ -o data data.cpp -O3 -std=gnu++20 -Wall -Wextra -Wshadow -D_GLIBCXX_ASSERTIONS -ggdb3 -fmax-errors=2 -DLOCAL
// run: ./data < data.in
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#ifdef LOCAL
#include <debug/codeforces.h>
#define debug(x...) {_variables(#x);_print(x);}
#else
#define debug(x...)
#endif
template<typename...Args> void print_(Args...args){((cout<<args<<" "),...)<<endl;}
#define rep(i,a,b) for(int i=(a);i<(int)(b);++i)
#define sz(v) ((int)(v).size())
#define print(...) print_(__VA_ARGS__);
#define INTMAX (int)(9223372036854775807)
#define INTINF (int)(1152921504606846976)
#define int long long
#define MAXN 200010
#define MAXM 10000010

// bool valid[MAXM];

// void dfs(int k) {
//     if (valid[k]) return;
//     valid[k] = 1;
//     if (k % 3) return;
//     dfs(k / 3);
//     dfs(2*k / 3);
// }

int pow3[32];

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    pow3[0] = 1;
    rep(i, 1, 32) pow3[i] = pow3[i-1] * 3;
    int _; cin >> _;
    while (_--) {
        int n, m; cin >> n >> m;
        bool valid = 0;
        for (int i = 0; i <= 30; ++i) {
            for (int j = 0; j <= i; ++j) {
                if (n*(1<<j) % pow3[i] == 0 && n*(1<<j)/pow3[i] == m) {
                    valid = 1;
                    break;
                }
            }
            if (valid) break;
        }
        cout << (valid ? "YES" : "NO") << endl;
    }

    return 0;
}

Comments

  1. 10 months ago
    2025-12-06 2:44:21

    Curious about 123win94. Hoping to finding some fun and maybe even winning something! Well, here is hoping! Give it a shot yourself: 123win94

  2. 9 months ago
    2025-12-19 13:58:31

    Alright, betvn1vip, let’s see what you got! Gave it a whirl, and it’s not bad, not bad at all. Good selection. Could use a little something extra, but overall, I’m feeling it. You might dig it too! betvn1vip

  3. 9 months ago
    2025-12-29 6:26:54

    KG77casino… Never heard of it before, but I gave it a try. Honestly, pleasantly surprised! Good game variety, and the bonuses seem pretty competitive. I’m digging it! Check them out. kg77casino

  4. 8 months ago
    2026-1-26 20:55:08

    Taizowin, never heard of it before. Anyone got an invite code they wanna throw my way? Always down to check out a new platform. taizowin

  5. 8 months ago
    2026-1-26 20:55:24

    Looking for some reliable bookies. Tic88bet good for sports betting? Lots of asian handicaps? Let me know if anyone’s used them successfully for football wagers. tic88bet

  6. 8 months ago
    2026-1-26 20:55:39

    Hey, people! Looking for a new gambling spot? 5699win might be your game. I found it the other day by some random forum. Check it out here: 5699win

  7. 7 months ago
    2026-2-20 22:49:40

    Thinking of giving Fun88za a bash tonight. Anyone else use them? Let me know what you think! Find out more fun88za

  8. 7 months ago
    2026-2-20 22:49:56

    Alright iOS users, g666ios looks interesting. Seems like they’re catering specifically to you guys. Might be worth checking out. Here is the link g666ios.

  9. 7 months ago
    2026-2-20 22:50:12

    Looking for how to tải vn123? You can find what you need here. Check it out here tải vn123.

  10. 3 weeks ago
    2026-8-27 8:42:10

    The graphics are stunning and the gameplay is just buttery smooth. It is a great place to unwind after a long day of work. Give bb444login a try.

  11. 2 weeks ago
    2026-9-02 4:47:38

    I have tested dozens of betting sites and this one stands out for its genuine player first approach. The welcome bonus translated into actual playing credits and the support team answered my questions within seconds. It feels like a community rather than just a casino. a2betlink

  12. 3 days ago
    2026-9-15 13:02:21

    I’ve been playing here for a while now and the payouts are surprisingly fast. Definitely one of the more reliable spots I’ve found lately. Check out vneu88

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
Previous
Next