Cod sursa(job #1368712)
Utilizator | Data | 2 martie 2015 19:33:54 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include<fstream>
#define baza 1999999973
using namespace std;
long long n, p, nr;
ifstream in("lgput.in");
ofstream out("lgput.out");
int main(){
in>>n>>p;
nr=1;
while(p!=0){
if(p%2==1)
nr=(nr*n)%baza;
n=(n*n)%baza;
p/=2;
}
out<<nr;
}