Cod sursa(job #1913281)
Utilizator | Data | 8 martie 2017 12:26:17 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
const int mod = 1999999973;
ll n,p;
ll lgpow(ll x,ll p){
ll r = 1;
while(p){
if(p & 1){
p--;
r = (r * x) % mod;
}
x = (x * x) % mod;
p /= 2;
}
return r;
}
int main()
{
f >> n >> p;
g << lgpow(n,p) << '\n';
return 0;
}