Problem:
Reflection

For given three points p1, p2, p, find the reflection point x of p onto p1p2.

Input

xp1 yp1 xp2 yp2
q
xp0 yp0
xp1 yp1
...
xpq−1 ypq−1

In the first line, integer coordinates of p1 and p2 are given. Then, q queries are given for integer coordinates of p.

Output

For each query, print the coordinate of the reflection point x. The output values should be in a decimal fraction with an error less than 0.00000001.

Constraints

1 ≤ q ≤ 1000

-10000 ≤ xi, yi ≤ 10000

p1 and p2 are not identical.

Sample Input 1

0 0 2 0
3
-1 1
0 1
1 1

Sample Output 1

-1.0000000000 -1.0000000000
0.0000000000 -1.0000000000
1.0000000000 -1.0000000000

Sample Input 2

0 0 3 4
3
2 5
1 4
0 3

Sample Output 2

4.2400000000 3.3200000000
3.5600000000 2.0800000000
2.8800000000 0.8400000000

Solution in C# (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;

/*

  Points/Vectors - Projection
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_A

  ?????????????°???±????±?????????????
  ??¨???: Vec2f ??? float ??§?¨????????????¨???????????????

 */

class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }

    // a, b ????????´??????????????????p ????????????????°???±?????????????±???????
    static void Calc(Vec2f p, Vec2f a, Vec2f b) {
        var ab = b - a;
        var ap = p - a;

        var d = ab.Normalized().Dot(ap);
        var m = a + ab.Normalized() * d;

        var pm = m - p;
        var px = 2 * pm;
        var x = p + px;
        Console.WriteLine("{0:f8} {1:f8}", x.X, x.Y);
    }

    static void Main() {
        var xs = ReadInts();
        var p1 = new Vec2f(xs[0], xs[1]);
        var p2 = new Vec2f(xs[2], xs[3]);

        int q = ReadInt();
        for (int i = 0; i < q; i++) {
            var xy = ReadInts();
            var p = new Vec2f(xy[0], xy[1]);
            Calc(p, p1, p2);
        }
    }
}

struct Vec2f {
    public double X { get; private set; }
    public double Y { get; private set; }

    public Vec2f(double x, double y) : this() {
        X = x;
        Y = y;
    }

    public override string ToString() {
        return string.Format("({0}, {1})", X, Y);
    }

    public static Vec2f operator+(Vec2f a, Vec2f b) {
        return new Vec2f(a.X + b.X, a.Y + b.Y);
    }

    public static Vec2f operator-(Vec2f a, Vec2f b) {
        return new Vec2f(a.X - b.X, a.Y - b.Y);
    }

    public static Vec2f operator*(Vec2f a, double t) {
        return new Vec2f(a.X * t, a.Y * t);
    }

    public static Vec2f operator*(double t, Vec2f a) {
        return new Vec2f(a.X * t, a.Y * t);
    }

    // a???b = |a||b|cos??
    public double Dot(Vec2f other) {
        return X * other.X + Y * other.Y;
    }

    public double Cross(Vec2f other) {
        return X * other.Y - Y * other.X;
    }

    public Vec2f Normalized() {
        var m = Magnitude();
        if (m != 0 && m != 1) {
            return new Vec2f(X / m, Y / m);
        }
        return this;
    }

    public double Magnitude() {
        return Math.Sqrt(X * X + Y * Y);
    }

    public double SqrMagnitude() {
        return X * X + Y * Y;
    }

    public static double Distance(Vec2f a, Vec2f b) {
        return (a - b).Magnitude();
    }
}