Cod sursa(job #2224557)
Utilizator | Data | 24 iulie 2018 14:42:06 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
#define int long long
int lgput(int a, int n)
{
int ans = 1;
while(n > 0)
{
if(n & 1)
{
ans *= a;
ans %= MOD;
n--;
}
a = a * a;
a %= MOD;
n >>= 1;
}
return ans;
}
main()
{
int a, b;
fin >> a >> b;
fout << lgput(a, b);
}