Comments

It is showing invites are currently closed for this server

I am in. Please send link

Hey, I was using online compiler and didn't know that my code can be viewed by others. So sorry for this mistake. I will take care of it from the next time. As this was my first mistake I hope you will understand it and will not penalise me. I will make sure no such incident happen in future. Thanking You

include

include

include

using namespace std; typedef long long ll;

bool solve1(ll n, ll x, vector& dp) { if (n == x) { return true; } if (x > n || n % 3 != 0) { return false; } if (dp[n] != -1) { return dp[n]; } bool ans = solve1(n / 3, x, dp) || solve1(2 * n / 3, x, dp); dp[n] = ans ? 1 : 0; return dp[n]; }

void solve() { ll n, m; cin >> n >> m; vector dp(n + 1, -1); if (solve1(n, m, dp)) { cout << "YES" << endl; } else { cout << "NO" << endl; } }

int main() { cin.tie(0); cin.sync_with_stdio(0); cout.tie(0); cout.sync_with_stdio(0);

int t;
cin >> t;
while (t--) {
    solve();
}

return 0;

} Why this code is giving Time complexity in Problem D, ;Gold Rush?