Cod sursa(job #1524399)
Utilizator | Data | 14 noiembrie 2015 00:19:20 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
#define c 1999999973
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
int n,p;
int main()
{
int rez=1,power;
in>>n>>p;
power=n;
while(p)
{
if(p & 1) rez=(1ll*rez*power)%c;
power=(1ll*power*power)%c;
p>>=1;
}
out<<rez;
in.close();
out.close();
return 0;
}