Cod sursa(job #1824630)
| Utilizator | Data | 8 decembrie 2016 09:17:13 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <fstream>
#define MOD 1999999973
using namespace std;
unsigned int N, P;
unsigned long long int x;
unsigned long long int sol;
int main ()
{
ifstream fin ("lgput.in");
fin >> N >> P;
fin.close();
sol = 1;
x = N;
while (P)
{
if (P%2)
sol = (sol*x) % MOD;
x = (x*x) % MOD;
P /= 2;
}
ofstream fout ("lgput.out");
fout << sol;
fout.close();
return 0;
}
