Cod sursa(job #1599294)
| Utilizator | Data | 13 februarie 2016 19:10:22 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 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, i, x;
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;
}
