Cod sursa(job #2236915)
Utilizator | Data | 30 august 2018 22:28:19 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include<fstream>
#define mod %1999999973
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
long n,p;
int main()
{
int pow=1;
in>>n>>p;
while(p)
{
if(p%2)
{
pow=(pow*n)mod;
p--;
}
n=(n*n)mod;
p/=2;
}
out<<pow;
}