Cod sursa(job #1968239)
Utilizator | Data | 17 aprilie 2017 15:57:52 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <fstream>
#define MOD 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long p,n,exp,expp,rez;
int main()
{
f>>n>>exp;
rez=1;
while(exp!=0){
p=n;
expp=1;
while(expp*2<=exp){
expp*=2;
p=(p*p)%MOD;
}
rez=(rez*p)%MOD;
exp-=expp;
}
g<<rez;
return 0;
}