Cod sursa(job #908622)
Utilizator | Data | 9 martie 2013 21:02:09 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.29 kb |
#include<fstream>
#define mod 1999999973;
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n,p,k;
int main()
{
f>>n>>p;
k=1;
while(p!=0)
{
if(p%2==1)
k=(k*n)%mod;
n=n*n%mod;
p=p/2;
}
g<<k;
}