Cod sursa(job #1445920)
Utilizator | Data | 31 mai 2015 14:10:43 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.26 kb |
#include <fstream>
#define Xp 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n,p,x;
int main()
{
f>>n>>p;
x=1;
while(p) {if(p&1) x=(x*n)%Xp,p--; n=(n*n)%Xp; p/=2;}
g<<x;
g.close(); return 0;
}