Cod sursa(job #1956107)
Utilizator | Data | 6 aprilie 2017 14:59:53 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int n,p,x,mod=1999999973;
int main()
{f>>n>>p;
x=1;
while(p)
{
if(p%2==0)
{
p/=2;
n=(n*n)%mod;
}
else
{
x=(x*n)%mod;
p--;
}
}
g<<x;
return 0;
}