用来作弊的药水

快速幂, 花了好久还是掌握不好, 我......
#include<iostream>
using namespace std;
const int Mod = 1e9 + 3;
long long FastPower(long long a,long long b,int mod)
{
	long long result=1;
	while(b)
	{
		if( b & 1 )
			result = (result * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return result;
}
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		long long a, b, c, d;

		scanf("%lld %lld %lld %lld",&a, &b, &c, &d);

		if(FastPower(a,b,Mod)==FastPower(c,d,Mod))
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
}

从网上学的写法

好吧好吧, 我还有的学

猜你喜欢

转载自blog.csdn.net/someone_and_anyone/article/details/79745763