Cod sursa(job #2552241)
Utilizator | Data | 20 februarie 2020 18:17:07 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.26 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int main(){
const int m = 1999999973;
int p, i;
long long n, sol=1;
f>>n>>p;
while(p!=0){
if(p%2==1)
sol=(sol*n)%m;
n=(n*n)%m;
p/=2;
}
g<<sol%m<<" ";
return 0;
}