Cod sursa(job #1163494)
| Utilizator | Data | 1 aprilie 2014 13:36:06 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.32 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
unsigned long long i,n,p,k,x;
int main()
{
fin>>n>>p;
k=n;x=1;
for(i=0;(1<<i)<=p;++i)
{
if(((1<<i)&p)>0)x=(x*k)%mod;
k=(k*k)%mod;
}
fout<<x;
}
