题解 | #用来作弊的药水#

用来作弊的药水

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";
    }

}
全部评论

相关推荐

点赞 评论 收藏
分享
10-10 16:30
济宁学院 Java
不想做程序员:面试官:蓝桥杯三等奖?你多去两次厕所都能拿二等吧
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务