Cod sursa(job #2471299)
Utilizator | Data | 10 octombrie 2019 18:39:29 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | basic_stuff | Marime | 0.44 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int64_t n,p;
const int64_t MOD=1999999973;
int64_t powmodulo ()
{
int64_t b=1;
while (p)
{
if ((p&1))
{
b=((b%MOD)*(n%MOD))%MOD;
p--;
}
n=((n%MOD)*(n%MOD))%MOD;
p=(p>>1);
}
return b;
}
int main ()
{
f>>n>>p;
g<<powmodulo();
return 0;
}