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