Cod sursa(job #2283505)
Utilizator | Data | 15 noiembrie 2018 16:21:56 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <bits/stdc++.h>
#define rest 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long int n,p;
int main()
{
long long int x;
cin>>n>>p;
x=1;
while(p>0)
{
if(p%2==1)
x=(x*n)%rest;
n=(n*n)%rest;
p/=2;
}
cout<<x;
return 0;
}