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