Cod sursa(job #1669459)
| Utilizator | Data | 30 martie 2016 18:48:54 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.35 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;
t=t*t;
p=p/2;
}
g<<q;
f.close();
g.close();
return 0;
}
