Cod sursa(job #2047160)
| Utilizator | Data | 24 octombrie 2017 16:53:08 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.63 kb |
#include <bits/stdc++.h>
using namespace std;
const int modulo = 1999999973;
long long n, p;
void Read() {
ifstream fin("lgput.in");
fin >> n >> p;
fin.close();
}
long long Log_Pow(int base, int expo) {
int ans = 1;
while (expo) {
if (expo % 2 == 0) {
base *= base % modulo;
expo /= 2;
}
expo--;
ans *= base % modulo;
}
return ans;
}
void Write() {
long long ans = Log_Pow(n, p);
ofstream fout("lgput.out");
fout << ans << "\n";
fout.close();
}
int main()
{
Read();
Write();
return 0;
}
