Cod sursa(job #2200546)
Utilizator | Data | 1 mai 2018 18:44:54 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <fstream>
using namespace std;
#define w 1999999973
ifstream f("lgput.in"); ofstream g("lgput.out");
int main()
{ long long a, b, p = 1;
f >> a >> b;
while(b)
{
if(b % 2) p = (p % w) * (a % w), --b;
a = (a % w) * (a % w);
b /= 2;
}
g << p % w;
g.close(); f.close();
return 0;
}