Cod sursa(job #1541227)
| Utilizator | Data | 3 decembrie 2015 20:47:39 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.42 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const long long MOD = 1999999973;
int main()
{
long long n, p;
fin >> n >> p;
long long ans = 1;
while(p)
{
if( p % 2 )
{
ans = (ans * n) % MOD;
p--;
}
n = (n * n) % MOD;
p /= 2;
}
fout << ans << '\n';
return 0;
}
