Cod sursa(job #2460247)

Utilizator cristian51090Oanta Cristian cristian51090 Data 23 septembrie 2019 10:17:49
Problema Ridicare la putere in timp logaritmic Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.59 kb
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll power(ll a, ll n, ll mod) {ll p=1;while(n > 0){if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
template <typename T> inline T Pow(T base,T exp,T mod){ull x = 1, y = base;while(exp>0){if(exp&1) x = Mulmod(x,y,mod);y = Mulmod(y,y,mod);exp >>= 1;}return x;}
int main(){
ll a,b,c;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin>>a>>b;
c=1999999973;
fout << modpow(a,b,c);
return 0;
}