Cod sursa(job #3174515)
Utilizator | Data | 24 noiembrie 2023 20:53:41 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
//https://infoarena.ro/problema/lgput
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
long long n,p;
fin>>n>>p;
cout<<p;
long long rez=1;
while(p>0)
{
if(p&1)
{
rez=rez*n%1999999973;
}
p=p>>1;
n=n*n%1999999973;
/cout<<rez<<" ";
}
fout<<rez;
return 0;
}