HackerRank MathMar 17, 2025

Find the Point

Hazrat Ali

HackerRank Math

Consider two points,  and . We consider the inversion or point reflection, of point  across point  to be a  rotation of point  around .

Given  sets of points  and , find  for each pair of points and print two space-separated integers denoting the respective values of  and  on a new line.

Function Description

Complete the findPoint function in the editor below.

findPoint has the following parameters:

  • int px, py, qx, qy: x and y coordinates for points  and 

Returns

  • int[2]: x and y coordinates of the reflected point 

Input Format

The first line contains an integer, , denoting the number of sets of points.
Each of the  subsequent lines contains four space-separated integers that describe the respective values of , and  defining points  and .

Constraints

Sample Input

2
0 0 1 1
1 1 2 2

Sample Output

2 2
3 3

Explanation

The graphs below depict points , and  for the  points given as Sample Input:

  1. find-point-0011.png

  2. find-point-1122.png

 

Solution : 

#include<iostream>
using namespace std;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        cout << n + 1 << endl;
    }
    return 0;
}

 

 

Comments