Cod sursa(job #1771841)
Utilizator | Data | 6 octombrie 2016 08:21:11 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n, p;
void Read(){
fin >> n >>p;
}
void Solve(){
int sol = 1;
while(p){
if(p % 2 == 1)
sol = (sol * n) % 1999999973;
n = (n * n) % 1999999973;
p /= 2;
}
fout << sol << "\n";
}
int main(){
Read();
Solve();
return 0;
}