Cod sursa(job #1798744)
| Utilizator | Data | 5 noiembrie 2016 13:19:59 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.32 kb |
#include <fstream>
#include <stdio.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{ int64_t a,n,p;
fin>>a>>n;
p = 1;
while ( n > 0 ) {
if (n % 2 == 1)
p = p * a;
a = a * a;
n = n / 2;
}
fout<<p%1999999973;
return 0;
}
