Cod sursa(job #1945885)
Utilizator | Data | 29 martie 2017 18:52:41 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <bits/stdc++.h>
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
unsigned long long x, n, k, y;
fin>>x>>n;
y = x;
for(k = 1; 1<<k <= n; ++k) {
x = (x%MOD * x%MOD)%MOD;
}
for(k = (1<<(k-1))+1; k <= n; ++k) {
x = (x%MOD * y%MOD)%MOD;
}
fout<<x<<'\n';
return 0;
}