Cod sursa(job #1861249)
Utilizator | Data | 28 ianuarie 2017 18:48:52 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long s = 1;
int n, p;
void Rezolva()
{
fin >> n >> p;
int k = 1999999973;
while(p > 0)
{
if(p % 2 == 1)
{
s = (1LL * s * n) % k;
p--;
}
p /= 2;
n = (1LL * n * n) % k;
}
fout << s << "\n";
}
int main()
{
Rezolva();
return 0;
}