Codeforce-Power Tower(欧拉降幂)

Power Tower

题意:

  • 一个序列有个数,次询问,将到这个区间的数叠起来模上

思路:

  • 欧拉降幂
#include
#define ll long long
using namespace std;
mapmp;
const int M=1e5+10;
ll a[M];
ll ol(ll x)
{
    if(mp[x])
    {
        return mp[x];
    }
    ll ans=x;
    ll n=x;
    for(int i=2;i*i<=n;i++)
    {
        if(x%i==0)
        {
            ans=ans*(i-1)/i;
        }
        while(x%i==0)
        {
            x/=i;
        }
    }
    if(x>1)
    {
        ans=ans*(x-1)/x;
    }
    mp[n]=ans;
    return ans;
}
ll query(ll a,ll mod)
{
    if(a>=1;
    }
    return ans;
}
ll solve(int l,int r,ll mod)
{
    if(r==l||mod==1)
    {
        return query(a[l],mod);
    }
    ll d=solve(l+1,r,ol(mod));
    return pow(a[l],d,mod);
}
int main( )
{
    int n,q,l,r;
    ll mod;
    //cout<

你可能感兴趣的:(Codeforce-Power Tower(欧拉降幂))