Cod sursa(job #1100973)
| Utilizator | Data | 7 februarie 2014 18:57:51 | |
|---|---|---|---|
| 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
typedef long long int lli;
lli n,p;
int power(long long int x)
{
if(x==1)
return n%mod;
else
if(x%2==1)
return n*(lli)pow(power(x/2),2)%mod;
else
return (lli)pow(power(x/2),2)%mod;
}
int main()
{
f>>n>>p;
g<<power(p)%mod;
f.close();g.close();
return 0;
}
