Cod sursa(job #1601949)
Utilizator | Data | 16 februarie 2016 13:21:05 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
#include <iostream>
#define mod 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long p,n,numar=1;
int main()
{
f>>n>>p;
while(p>0)
{
if((p&1))
{
numar=(numar*n)%mod;
p--;
}
else
{
n=(n*n)%mod;
p=(p>>1);
}
}
g<<numar;
return 0;
}