Cod sursa(job #2499458)
Utilizator | Data | 26 noiembrie 2019 09:36:38 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
long long n, p, r;
int main ()
{
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
fin>>n>>p;
r=1;
while (p)
{
if (p%2==1)
r=(1LL*r*n)%mod;
n=(1LL*n*n)%mod;
p/=2;
}
fout<<r;
}