Cod sursa(job #1054287)
| Utilizator | Data | 13 decembrie 2013 17:21:29 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 30 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 kb |
#include <fstream>
#include <math.h>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
#define mod 1999999973
long long int n,p;
int power(long long int x)
{
if(x==1)
return n%mod;
else
if(x%2==1)
return ((long long int) (n%mod*pow(power(x/2),2)))%mod;
else
return ((long long int) pow(power(x/2),2))%mod;
}
int main()
{
f>>n>>p;
g<<power(p);
f.close();g.close();
return 0;
}
