Cod sursa(job #2070364)
Utilizator | Vlad Haivas vladth11 | Data | 19 noiembrie 2017 14:39:33 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <fstream>
using namespace std;
ifstream cin("lgput.in");
ofstream cout("lgput.out");
int main()
{
int n,p,rez;
cin >> n >> p;
rez = 1;
while(p>0){
if(p%2==1){
rez = rez*n;
}
n = n*n;
p = p / 2;
}
cout << (long long)rez % 1999999973;
return 0;
}