Cod sursa(job #2143526)
Utilizator | Data | 26 februarie 2018 08:25:16 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long a,b,MOD=1999999973;
int rise(long long a, long long b) {
if(b == 0) return 1;
long x = rise(a, b / 2);
if(b % 2 == 0) return (x * x) % MOD;
return (((x * x) % MOD) * a) % MOD;
}
int main()
{fin >> a >> b;
fout<<rise(a,b);
return 0;
}