Cod sursa(job #1669468)
| Utilizator | Data | 30 martie 2016 18:58:00 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.38 kb |
#include<iostream>
#include<fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n,p,q,t;
int main()
{
f>>n>>p;
n=n%1999999973;
q=1;
t=n;
while(p!=0)
{
if(p%2==1)
q=(q*t)%1999999973;
t=(t*t)%1999999973;
p=p/2;
}
g<<q;
f.close();
g.close();
return 0;
}
