Cod sursa(job #1582771)
Utilizator | Data | 28 ianuarie 2016 14:19:52 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
long long rest = 1,N, P;
int main()
{
in>>N>>P;
while(P > 0){
if(P % 2 == 1){
rest = (rest*N) % 1999999973;
P--;
}
P = P/2;
N*= N % 1999999973;
}
out<<rest;
}