考察知识点:快速幂
题目很长,但是意思很简单,就是判断 和 是否相等。
使用快速幂优化即可。
时间复杂度:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
ll qpw(ll a, ll b, ll mod = 1e9 + 7)
{
ll res = 1;
while (b)
{
if (b & 1)
res = res * a % mod;
a = a * a % mod, b >>= 1;
}
return res;
}
void solve()
{
ll x, a, y, b;
cin >> x >> a >> y >> b;
if (qpw(x, a) == qpw(y, b))
cout << "Yes" << endl;
else
cout << "No" << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t = 1;
cin >> t;
while (t--)
solve();
return 0;
}