有理数取余

#include<bits/stdc++.h>
#define mo 19260817
using namespace std;
const int maxn=6e6+10;
int a,b;
inline void read(int &x)
{
	char ch=getchar();int f=1;x=0;
	while(!isdigit(ch) && ch^'-') ch=getchar();
	if(ch=='-') f=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',x%=mo,ch=getchar();
	x=(x*f)%mo;
}
long long ksm(long long x,long long y)
{
	long long cnt=1;
	while(y)
	{
		if (y&1) cnt=(cnt*x)%mo;
		x=(x*x)%mo;
		y>>=1; 
	}
	return cnt;
}
int main()
{
	read(a);
	read(b);
	if (b == 0)
	{
		cout << "Angry!" << endl;
		return 0;
	}
	cout << a*ksm(b,mo-2)%mo << endl;
	return 0;
}
posted @ 2026-04-16 15:12  msjing  阅读(16)  评论(0)    收藏  举报