Cod sursa(job #2346717)
Utilizator | Data | 18 februarie 2019 00:05:26 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.29 kb |
#include <bits/stdc++.h>
#define modulo 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long x,p,ans=1;
int main()
{ f>>x>>p;
while(p>0)
{ if(p%2==1) ans=(ans*x)%modulo;
x=(x*x)%modulo;
p/=2;
}
g<<ans%modulo;
return 0;
}