Cod sursa(job #2199728)
Utilizator | Data | 28 aprilie 2018 21:04:27 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
int main()
{
unsigned long long a,b;
const int mod = 1999999973;
fin >> a >> b;
unsigned long long rezultat = 1;
while (b){
if (b&1) rezultat = (rezultat* a) % mod;
b >>= 1;
a = (a * a) % mod;
}
fout << rezultat;
return 0;
}