#C12731. 2D Vector Operations

    ID: 42191 Type: Default 1000ms 256MiB

2D Vector Operations

2D Vector Operations

Implement a Vector class to represent a 2-dimensional mathematical vector. Your class should support the following operations:

  • Addition: Given two vectors \(v_1=(x_1,y_1)\) and \(v_2=(x_2,y_2)\), the sum is defined as \(v_1+v_2=(x_1+x_2,\; y_1+y_2)\).
  • Scalar Multiplication: Multiplying a vector \(v=(x,y)\) by a scalar \(k\) yields \(k\cdot v=(kx,\; ky)\).
  • Dot Product: The dot product of two vectors \(v_1=(x_1,y_1)\) and \(v_2=(x_2,y_2)\) is defined as \(x_1\times x_2 + y_1\times y_2\).
  • String Representation: The vector should be represented in the format Vector(x, y).

Your program will read input from stdin and output the results to stdout.

inputFormat

The input consists of three lines:

  1. The first line contains two integers representing the coordinates of the first vector, \(x_1\) and \(y_1\).
  2. The second line contains two integers representing the coordinates of the second vector, \(x_2\) and \(y_2\).
  3. The third line contains an integer representing the scalar for multiplication.

outputFormat

The output should consist of four lines:

  1. The result of vector addition v1 + v2 in the format Vector(x, y).
  2. The result of scalar multiplication v1 * k in the format Vector(x, y).
  3. The dot product of v1 and v2.
  4. The string representation of the first vector v1.
## sample
1 2
3 4
3
Vector(4, 6)

Vector(3, 6) 11 Vector(1, 2)

</p>