Cod sursa(job #2187043)
| Utilizator | Data | 26 martie 2018 10:12:40 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.54 kb |
#include <iostream>
#include <fstream>
using namespace std;
const int mod=1999999973;
int main()
{
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
int a,b,c=1;
fin>>a>>b;
if (b==0)
fout<<1;
else
{
while(b>1)
if (b%2==0)
{
a=(1LL * a*a)%mod;
b/=2;
}
else
{
c=(1LL * c*a)%mod;
b--;
}
fout<<(1LL * c*a)%mod;
}
return 0;
}
