Help me in solving INSM03 problem

My issue

please tell me the approach for this question

My code

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	return 0;
}

Problem Link: INSM03 Problem - CodeChef

@rg356403
Hint :- think of GCD