碧蓝书本

文章
3
资源
0
加入时间
3年1月8天

逆元的几种求法

1、快速幂直接求(要求取模的数为质数)由费马小定理可得,如果p为质数,则a^(p-1)%c=1=a*a^(p-2)%c;如果a*b%mod=1;则a为b的逆元,b也为a的逆元。a的逆元为a^(mod-2).ll pow_mod(ll a,ll b){  ll res=1;  while(b){  if(b&1) res=res*a%mod;  b...

linux获取hostname和获取ip

1.获取hostnamechar host[MAX_HOST_NAME];gethostname(host, MAX_HOST_NAME - 1); //Get host namestring hostName(host);2.获取ip#include #include #include #include #include #include int m