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