Cod sursa(job #2223869)
Utilizator | Data | 21 iulie 2018 21:10:50 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include <fstream>
using namespace std;
long long n,p,x=1;
const int mod=1999999973;
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
f>>n>>p;
while(p)
{
if(p%2==1)
{
x=(x*n)%mod;
p--;
}
n=(n*n)%mod;
p/=2;
}
g<<x;
return 0;
}