Cod sursa(job #2341552)
Utilizator | Data | 11 februarie 2019 22:21:59 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int n, p;
void desc(){
int sol = 1;
while(p != 0){
if(p % 2 == 1)
sol = (1LL * sol * n) % mod;
n = n * n;
p = p / 2;
}
fout << sol % mod << endl;
}
int main(){
fin >> n >> p;
desc();
fin.close();
fout.close();
return 0;
}