Cod sursa(job #1574633)
| Utilizator | Data | 20 ianuarie 2016 18:49:08 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.57 kb |
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
const long long mod = 1999999973;
long long n, p;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long fastPow(long long a, long long b)
{
long long ans = 1;
while(b)
{
if(b&1)
{
b--;
ans = (ans*a)%mod;
}
b/=2;
a = (a*a)%mod;
//cout << ans << "\n";
}
return ans;
}
int main()
{
fin >> n >> p;
fout << fastPow(n, p);
}
