Cod sursa(job #2113897)
| Utilizator | Data | 25 ianuarie 2018 11:15:09 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
#include <fstream>
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
typedef unsigned long long ull;
ull MOD=1999999973;
ull put(ull a,ull b)
{
if(b==0)return 1;
if(b==1)return a;
ull aux=put(a,b/2);
if(b&1)return(((aux*aux)%MOD)*a)%MOD;
return (aux*aux)%MOD;
//b&1 = b este impar
}
ull a,b;
int main()
{
fin>>a>>b;
fout<<put(a,b);
fin.close(); fout.close();
return 0;
}
