Cod sursa(job #2149210)
Utilizator | Data | 2 martie 2018 13:30:07 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long sol,n,p;
int main()
{
fin>>n>>p;
sol=1;
while(p)
{
if(p%2==1)
sol=(sol*n)%mod;
n=(n*n)%mod;
p/=2;
}
fout<<sol%mod;
return 0;
}