Cod sursa(job #1373159)
| Utilizator | Data | 4 martie 2015 17:04:37 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
const int MOD = 1999999973;
long long N,P,Solution=1;
void Read(){
f>>N>>P;
}
void Solve(){
while (P) {
if (P%2 == 1) {
Solution = (Solution * N) % MOD;
}
N =(N * N) % MOD;
P = P/2;
}
}
void Write(){
g<<Solution;
}
int main()
{
Read();
Solve();
Write();
return 0;
}
