Cod sursa(job #2758919)
Utilizator | Data | 14 iunie 2021 10:48:51 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int main()
{
int MOD=1999999973;
int n, p;
f>>n>>p;
long long a=1;
while(p)
{
if(p%2==1)
a=(a*n)%MOD;
n=(n*n)%MOD;
p/=2;
}
g<<a;
return 0;
}