Cod sursa(job #1456312)
Utilizator | Data | 30 iunie 2015 12:14:20 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
int main()
{
int i;
int n;
int p;
int rez;
in>>n;
in>>p;
for(i=1;(1<<i)<=p;i++){
if((p &(1<<i))>0){
rez=(rez*n)% 1999999973;
n=(n*n)%1999999973;
}
}
out<<rez;
}