Shift Dot

Time Limit: 1000 ms Memory Limit: 65536 KiB
Submit Statistic
Problem Description
Give a point in the plane rectangular coordinate system, and sequentially give n vectors, find the position of the point after displacement according to the given n vectors.

Input
Multiple sets of input, the first line is three integers x, y, n, representing the coordinates (x, y) of the point, and the number of vectors n. The next n lines, each line has two numbers xi, yi, representing the ith vector. All data in the question will not exceed the shaping range.
Output
One line per group of input and output, "(x,y)" represents the final position of the point.
Sample Input
0 0 1
2 3
0 0 2
1 2
2 3
Sample Output
(2,3)
(3,5)
Hint

Source

import java.util.*;

class myclass {

}

class Main {
    public static void main(String[] args) {

        Scanner ss = new Scanner(System.in);
        //int n;// , m;
        final int mm = 205;
        int x, y, n;
        while (ss.hasNextLine()) {
            x = ss.nextInt();
            y = ss.nextInt();
            n = ss.nextInt();
            int xx, yy;
            while(n > 0) {
                xx = ss.nextInt();
                yy = ss.nextInt();
                x += xx;
                y+= yy;
                n--;
            }
            System.out.printf("(%d,%d)\n", x, y);
        }
        ss.close();
    }
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325989111&siteId=291194637