Cod sursa(job #2669299)
Utilizator | Data | 6 noiembrie 2020 18:12:57 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.4 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)
{
ll rez = 1;
while(b)
{
if(b & 1)
rez = (rez * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return rez;
}
int main()
{
ll a,b;
f >> a >> b;
g << pow(a,b);
}