Cod sursa(job #1995467)
Utilizator | Data | 28 iunie 2017 00:49:03 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
#define MOD 1999999973
int n,p;
long long rez=1;
int main()
{
fin>>n>>p;
for(int k=p; k; k>>=1)
{
if(k&1)
rez=1LL*rez*n%MOD;
n=1LL*n*n%MOD;
}
fout<<rez%MOD;
fin.close();
fout.close();
return 0;
}