Cod sursa(job #2669285)
Utilizator | Data | 6 noiembrie 2020 17:48:53 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
#define mod 1999999973
typedef long long ll;
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
ll pow(ll a, ll b)
{
if(b == 1)
return a % mod;
if(b & 1)
return (a % mod * pow(a, b - 1) % mod) % mod;
else
{
ll x = pow(a, b / 2) % mod;
return x * x % mod;
}
}
int main()
{
ll a,b;
f >> a >> b;
g << pow(a,b);
}