Cod sursa(job #1910273)
Utilizator | Data | 7 martie 2017 16:16:12 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
#define mod 1999999973
int main()
{
long long N, P, rez;
rez = 1;
f >> N >> P;
while(P > 0){
if(P % 2 == 1)
rez = (rez * N) % mod;
P = P / 2;
N = (N * N) % mod;
}
g << rez % mod;
return 0;
}