Cod sursa(job #3259011)
Utilizator | Data | 24 noiembrie 2024 17:55:16 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long number = 1999999973;
int main() {
long long N, P;
f>>N>>P;
long long produs=1;
while(P){
if(P%2==1){
produs *= N;
}
N *= N;
P /= 2;
}
g<<produs%number;
return 0;
}