题解 | #用来作弊的药水#
用来作弊的药水
https://ac.nowcoder.com/acm/problem/15324
因为x,a,y,b<=1e9,所以爆long long,定义一个在1e9之的模,其他的就是简单的快速幂
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int mod=1e9+1;
ll qpow(ll a,ll b)
{
ll ans=1;
ll base=a%mod;
while(b)
{
if(b&1) ans=(ans*base)%mod;
base=(base*base)%mod;
b>>=1;
}
return ans;
}
int main()
{
int t;
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll x,a,y,b;
cin>>t;
while(t--)
{
cin>>x>>a>>y>>b;
ll s1=qpow(x,a);
ll s2=qpow(y,b);
if(s1==s2) cout<<"Yes\n";
else cout<<"No\n";
}
}
