Cod sursa(job #1599296)
| Utilizator | Data | 13 februarie 2016 19:11:25 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <fstream>
#include <cmath>
#define MOD 1999999973
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
unsigned long long int N, P;
unsigned short int x;
unsigned short int i;
unsigned long long int sol;
int main ()
{
fin >> N >> P;
sol = 1;
x = N;
while (P != 0)
{
if (P%2 == 1)
{
sol = (sol*x) % MOD;
}
x = (x*x) % MOD;
P = P/2;
}
fout << sol;
return 0;
}
