Output of the given program
#include
#include
#include "mpi.h"
using namespace std;
//g^x = h mod p, find x. ex: 7^x = 15 mod 41, x = 3
main(int argc, char* argv[]) {
int rank;
int size;
int g;
int x;
int h;
int p;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
if(rank == 0) {
ifstream in;
in.open("num.txt");
in >> g;
in >> h;
in >> p;
ofstream out;
out.open("DL.txt");
for(int i = 0; i < size; i++) {
out << x << endl;
}
}
MPI_Finalize();
}
Attachment:- homework.zip