Cod sursa(job #2976929)
Utilizator | Data | 10 februarie 2023 13:12:17 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int m = 1999999973;
void put(long long &a, long long &b)
{
long long k = 1;
while(b)
{
if (b % 2 == 1)
{
k = (k * a) % m;
}
a = ((a % m) * (a % m)) % m;
b /= 2;
}
a = k;
}
int main()
{
long long a, b;
fin>>a>>b;
put(a, b);
fout<<a;
return 0;
}