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