快读__int128

128在c++库里面有定义但是没有定义他的读入读出

所以需要自己写个快读(在dev可编译成功,codeblock不行)

用128写的快速幂

#include 
 
using namespace std;
 
typedef __int128 ll;
typedef long double ld;
 
const ll maxn = 1e5 + 5;
 
void scan(ll &a)
{
     a = 0;
     ll f = 1;
     char c = getchar();
     while(c < '0' || c > '9') {if(c == '-') f = -1;c = getchar();}
   
     while(c >= '0' && c <= '9') a = a * 10 + c - '0',c = getchar();
   	
     a = a * f;
}
  
void prin(ll a)
{
    if(a > 9) prin(a / 10);
    putchar(a % 10 + '0');
}

void print(ll a)
{
    if(a < 0) a = -a, putchar('-');
    prin(a);
} 
 
ll qpow(ll a,ll b,ll mod) 
{
    ll ans = 1;
    a %= mod;
    while(b) 
    {
        if(b & 1)ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

int main() 
{
    //ios::sync_with_stdio(0);
    //cin.tie(0),cout.tie(0);
 
    ll n;
    scan(n);
    while(n--) 
    {
        ll a,b,mod;
        scan(a),scan(b),scan(mod);
        a = qpow(a,b,mod);
        print(a);
        cout << endl;
    }
 
    return 0;
}

 

你可能感兴趣的:(知识点)