Cod sursa(job #2104184)
Utilizator | Data | 11 ianuarie 2018 12:41:08 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <iostream>
#include <math.h>
#include<fstream>
using namespace std;
int N,P;
long long putere,modul;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
void Impartire()
{fin>>N>>P;
if(N%2==0)
putere=pow(N*N,P/2);
else
putere=N*pow(N*N,(P-1)/2);
modul=putere%1999999973;
}
int main()
{
Impartire();
fout<<modul;
return 0;
}