Help me in solving COPS problem

My issue

What algorithm should be used to solve this problem

My code

#include <iostream>
#include <bits/stdc++.h>
#define rep(i,a,n) for(long long i=a;i<n;i++)
#define ll long long
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n,x,y;
        int mul = x*y;
    return 0;

Problem Link: COPS Problem - CodeChef

For each, cop can go x*y distance forward and backward .
so u have to check for each cop and visit the houses x*y in forward and backward direction and then return the count of house that is not visited by any cop.