Cod sursa(job #1254764)
| Utilizator | Data | 3 noiembrie 2014 13:57:46 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.45 kb |
// ridicare la putere in timp logaritmic
#include <fstream>
using namespace std;
ifstream is("lgput.in");
ofstream os("lgput.out");
typedef long long ll;
ll f(int a, int b)
{
if( b == 1 )
return a;
ll val = f(a, b/2);
if( b % 2 == 1 )
return val*val%1999999973*a%1999999973;
return val*val%1999999973;
}
int main()
{
int n, p;
is >> n >> p;
long long m;
m = f(n, p);
os << m % 1999999973;
is.close();
os.close();
return 0;
}
