Cod sursa(job #1939909)
| Utilizator | Data | 26 martie 2017 10:05:44 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
#define m 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n,p,r;
int main()
{
fin>>n>>p;
r=1;
while(p>=1)
{
if(p%2!=0)
r=((r%m)*(n%m))%m;
n=((n%m)*(n%m))%m;
p=p/2;
}
fout<<r;
return 0;
}
