54 lines
873 B
C++
54 lines
873 B
C++
#include <cstdint>
|
|
#include <cstdlib>
|
|
#include <iostream>
|
|
#include <ostream>
|
|
#include <string>
|
|
|
|
using ll = int64_t;
|
|
|
|
ll a,b;
|
|
|
|
ll exgcd(ll a,ll b,ll&x,ll&y){
|
|
if(b==0){
|
|
x=1,y=0;
|
|
return a;
|
|
}
|
|
ll d = exgcd(b,a%b,x,y);
|
|
ll tmpy = y;
|
|
y = x-a/b*y;
|
|
x=tmpy;
|
|
return d;
|
|
}
|
|
|
|
ll inv(ll a,ll p){
|
|
ll x,y;
|
|
if(exgcd(a,p,x,y)!=1){
|
|
std::cout<<"Angry!\n"<<std::endl;
|
|
exit(0);
|
|
}
|
|
while(x<0){
|
|
x=(x%p+p)%p;
|
|
}
|
|
return x%p;
|
|
}
|
|
|
|
ll str2num(const std::string &str,const ll &p){
|
|
ll num{};
|
|
for(const auto&s:str){
|
|
num=(num*10+(s-'0'))%p;
|
|
}
|
|
return num;
|
|
}
|
|
|
|
const ll p{19260817};
|
|
|
|
int main(){
|
|
std::string stra,strb;
|
|
std::cin>>stra>>strb;
|
|
a=str2num(stra, p),b=str2num(strb, p);
|
|
if(b==0){
|
|
std::cout<<"Angry!\n";
|
|
return 0;
|
|
}
|
|
std::cout<<(a*inv(b,p))%p<<'\n';
|
|
} |