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