Cod sursa(job #2131940)
| Utilizator | Data | 15 februarie 2018 10:20:55 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
const int mod = 1999999973;
inline long long Put(int x, int n) {
long long p = 1;
while(n > 0) {
if(n % 2 == 1) {
p = (1LL * p * x) % mod;
n--;
}
x = (1LL * x * x) % mod;
n = n / 2;
}
return p;
}
int main()
{
long long n, m;
f >> n >> m;
g << Put(n, m) << "\n";
return 0;
}
