Cod sursa(job #2084841)
Utilizator | Data | 9 decembrie 2017 12:16:15 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include <fstream>
#define lol 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n,p;
long long P;
int main()
{P=1;
f>>n>>p;
while(p){
if(p&1)
P=((P%lol)*(n%lol))%lol;
p=p>>1;
n=((n%lol)*(n%lol))%lol;
}
g<<P%lol;
return 0;
}