Cod sursa(job #2104166)
Utilizator | Data | 11 ianuarie 2018 12:15:10 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
long long m,n,x,a;
int main()
{
in>>n >>x;
m=1999999973;
a=1;
while(x>0){
if(x&1==1){
a=(a*n)%m;
}
n=(n*n)%m;
x=x/2;
}
out<<a;
return 0;
}