Cod sursa(job #979101)
Utilizator | Data | 31 iulie 2013 17:21:43 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
unsigned long long n,p,a=1;
fin>>n>>p;
for(;p>1;p>>=1)
{
if(p%2==1)
a=a*n%1999999973;
n=n*n%1999999973;
}
fout<<n*a%1999999973;
}