Cod sursa(job #1041326)
Utilizator | Data | 25 noiembrie 2013 19:02:56 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include<fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int p;
long long x,n,k;
int main()
{
f>>n>>p;
k=1999999973;
x=1;
while(p!=0)
{
if(p%2==1)
{
x=x*n;
x=x%k;
}
p=p/2;
n=n*n;
n=n%k;
}
g<<x<<'\n';
g.close();
return 0;
}