Cod sursa(job #2278286)
Utilizator | Data | 7 noiembrie 2018 16:09:24 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
ifstream f ("lgput.in");
ofstream g ("lgput.out");
int k=1999999973;
int exp(int x,int y)
{
x%=k;
if(y==0)
{
return 1;
}
return x*exp(x*x,(y-(y&1))/2);
}
int main()
{
long int n,p;
f>>n>>p;
//g<<exp(n,p);
n=pow(n,p);
g<<n%k;
}