Cod sursa(job #3252123)
| Utilizator | Data | 28 octombrie 2024 17:04:40 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include<fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int mod = 1999999973;
long long fast_exp(long long a, int b)
{
long long ans = 1;
while(b)
{
if(b%2)
ans = (ans*a)%mod;
a = (a*a)%mod;
b /= 2;
}
return ans;
}
int main()
{
long long n, p;
fin>> n>> p;
fout<< fast_exp(n%mod, p);
fin.close();
fout.close();
return 0;
}
