纳米猫猫(欧拉函数)
作者:互联网
#include <bits/stdc++.h> using namespace std; using ll = long long ; ll euler(ll n){ ll k=n; for(ll i=2;i*i<=n;i++) if(n%i==0){ k-=k/i; while(n%i==0)n/=i; } if(n>1)k-=k/n; return k; } ll mi(ll a,ll b,ll mod){ ll r=1; while(b){ if(1&b)r=r*a%mod; a=a*a%mod; b>>=1; } return r; } int main() { ios::sync_with_stdio(false); string n; ll x,mod; cin>>x>>n>>mod; ll mod1=euler(mod); ll r=0; for(auto t:n) r=(r*10+t-'0')%mod1; r=(r+mod1-1)%mod1; cout<<mi(x,r,mod)%mod; }View Code
标签:mod1,a%,猫猫,ll,long,纳米,euler,欧拉,mod 来源: https://www.cnblogs.com/qq1415584788/p/14941695.html