Cod sursa(job #2134577)
| Utilizator | Data | 18 februarie 2018 09:19:46 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <fstream>
#define m 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
int n, p;
fin >> n >> p;
long long xlaputere = n;
long long rez = 1;
while(p >= 1)
{
if(p % 2 > 0)
rez = (rez % m) * (xlaputere % m) % m;
xlaputere = (xlaputere % m) * (xlaputere % m) % m;
p /= 2;
}
fout << rez << '\n';
return 0;
}
