欧拉降幂

https://codeforces.com/contest/1594/problem/E1

很容易推出:ans=6*(4^(2^k-2)))%mod;

k<=60

2^60在long long 内

幂次用一次快速幂,然后求出幂次再用一次快速幂

(注意求幂次ksm的时候不能mod,不然答案会变化)

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
const int mod=1e9+7;
const int N=2e5+5;
ll ksm(ll u,ll t){
    ll res=1;
    while(t>0){    
        if(t&1)res=res*u%mod;
        u=u*u%mod;
        t>>=1;
    }
    return res;
}
ll ksm2(ll u,ll t){
    ll res=1;
    while(t>0){
        if(t&1)res=res*u;
        u=u*u;
        t>>=1;
    }
    return res;
}
void solve(){
    int k;
    cin>>k;
    cout<<6*ksm(4,ksm2(2,k)-2)%mod<<endl;
    //cout<<ans*ksm(4,ksm(2,k)-2)%mod<<endl;
}
int main(){
    ios::sync_with_stdio(false);
      cin.tie(0);
//    int t;
//    cin>>t;
//    while(t--){
        solve();
//    }
    return 0;
}

 

posted @ 2022-07-23 18:15  Candyk8d9  阅读(37)  评论(0)    收藏  举报