Cod sursa(job #2199726)
Utilizator | Data | 28 aprilie 2018 20:56:21 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 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 *= a%mod;
b >>= 1;
a *= a%mod;
}
fout << rezultat;
return 0;
}