Cod sursa(job #1166546)
| Utilizator | Data | 3 aprilie 2014 17:38:51 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.37 kb |
#include<fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long int n,p,rez;
int main()
{
fin>>n>>p;
rez=1;
while(p)
{
if(p%2==1)
{
rez=rez*n%1999999973;
p--;
}
n*=n;
n%=1999999973;
p/=2;
}
fout<<rez;
return 0;
}
