Cod sursa(job #3213606)
Utilizator | Data | 13 martie 2024 12:10:40 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
int Put(int a, int b)
{
int p = 1;
while(b)
{
if (b % 2)
p = 1LL * a * p % MOD;
b /= 2;
a = 1LL * a * a % MOD;
}
return p;
}
int main()
{
int a, b;
fin >> a >> b;
fout << Put(a, b);
return 0;
}