Cod sursa(job #2562316)
Utilizator | Data | 29 februarie 2020 13:28:03 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
int P (int n , int m)
{
int p = 1;
while (m != 0)
{
if (m % 2 == 1)
{
p = 1LL * p * n % 1999999973;
}
n = n * n;
m /= 2;
}
return p;
}
int main()
{
int n , m;
fin >> n >> m;
fout << P(n , m);
return 0;
}