Cod sursa(job #1644677)
Utilizator | Data | 10 martie 2016 08:06:32 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int n, b, m;
int c, rez;
int main()
{
f >> n >> b;
c = n, rez = 1;
for (;b;b>>=1)
{
if (b&1)
rez = (rez*c)%mod;
c = (c*c)%mod;
}
g << rez;
return 0;
}