浅学一下和exgcd有关但是能够用费马小定理过掉的傻逼题


感觉这道题的最关键点的地方是大数据快读,我觉得学到很多,需要注意先要把非数字的都吃掉,然后再读。

题目链接:P2613 【模板】有理数取余 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)

#include
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define int long long

using namespace std;
const int mod=19260817;
int a,b;
void read(int &p)
{
	char ch=getchar();
	p=0;
	while(ch>'9'||ch<'0') ch=getchar();
	while(ch>='0'&&ch<='9') p=(p*10%mod+ch-'0')%mod,ch=getchar(); 
} 
int qmi(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1) res*=a,res%=mod;
		a*=a,a%=mod;
		b>>=1;
	}
	return res;
}

main()
{
	read(a);
	read(b);
	if(b) cout << a*qmi(b,mod-2)%mod;
	else puts("Angry!");
}