Cod sursa(job #2332606)
Utilizator | Data | 30 ianuarie 2019 21:48:04 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
unsigned long long n, k;
fin >> n >> k;
unsigned long long pw = n, rez = 1;
while(k){
if(k & 1){
rez *= pw;
rez %= MOD;
}
pw *= pw;
pw %= MOD;
k >>= 1;
}
fout << rez << '\n';
return 0;
}