Cod sursa(job #1113082)
| Utilizator | Data | 20 februarie 2014 12:20:16 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int temp;
long long int power(long long int a, long long int b)
{
if(b == 0) return 1;
if(b == 1) return a;
temp = power(a, b/2);
return temp*temp*power(a, b%2);
}
int main()
{
long long int n, p;
fin>>n>>p;
long long int res = power(n, p);
fout<<res%1999999973<<endl;
return 0;
}
