Cod sursa(job #2216357)
Utilizator | Data | 26 iunie 2018 14:40:26 | |
---|---|---|---|
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;
#define int long long
const int m = 1999999973;
int n,p;
int x,ans = 1;
signed main() {
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin >> n >> p;
x = n;
for (int i = 0; (1 << i) <= p; i++){
if (((1 << i) & p) > 0)
ans = (ans * x) % m;
x = (x * x) % m;
}
fout << ans;
}