Cod sursa(job #3210385)
Utilizator | Data | 6 martie 2024 09:55:58 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const long long int MOD = 1999999973;
unsigned long long int n, k, p = 1;
int main()
{
fin >> n >> k;
while(k != 0) {
if(k % 2 == 1) p *= n, p %= MOD;
n *= n, n %= MOD;
k /= 2;
}
fout << p;
return 0;
}