2111 - I2P(I)2020_Yang_lab3 Scoreboard

Time

2020/10/06 18:30:00 2020/10/06 20:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11134 Swap number
12893 Let's build a sequence

11134 - Swap number   

Description

In a shell game, balls with different numbers are hidden beneath identical containers, which are placed in a line. After the containers are shuffled, players need to guess the order of balls.

 

In this problem, there are five balls, numbered 0-4, and placed under five identical containers. The containers are placed in a straight line, and the initial positions of balls are from 0-4. The problem will then give k swaps of containers. Each swap is represented by a pair of integers, (a,b), meaning the container in position a is swapped with the container in position b. Your program needs to print the final ordering of balls.

 

For example, k=3, and three swaps are

0 4

2 3

1 2

 

Initially, the order of balls is: 0 1 2 3 4. After the swap (0,4), the order of balls becomes: 4 1 2 3 0; After the swap (2,3), the order of balls becomes: 4 1 3 2 0; and after the swap (1,2), the order of balls becomes:

4 3 1 2 0. So your program needs to print

4 3 1 2 0

 

hint:

To swap two numbers, a and b, you can use following code:

int temp;

temp = a;

a = b;

b = temp;

 

Input

The first line of the input is an integer k (0 < k < 25), which specifies the number of swaps. In the next k lines, each line contains a pair of integers, specifying the two positions to be swapped.

Output

The order of balls after swaps. Note that you do not need to print ‘\n’ at the end of the output.

Sample Input  Download

Sample Output  Download

Tags




Discuss




12893 - Let's build a sequence   

Description

There is a sequence a1, a2, a3, ..., aN.

Let's say that the difference between a1 and a2 is b1,
the difference between a2 and a3 is b2,
and so on.

That is, the difference between ai and ai+1 is bi.

We know that the sequence b1, b2, ... bN-1 is a arithmetic sequence.

An arithmetic sequence is a sequence of numbers such that the difference of any two successive members of the sequence is a constant.

Given you N, a1, a2, a3,
print the sequence a1, a2, a3, ... aN.

ouo.

Input

Input contains 2 lines.

The first line contains an integer N,
where N is the amount of number in the sequence.

The second line contains 3 integer a1, a2, a3,
where a1, a2, a3 are the first three number of the sequence.

It is a guarantee that:

3 <= N <= 200,
1 <= a1, a2, a3 <= 10^5

Output

Output contains only 1 line.

You should output a1, a2, ... aN and separate these numbers by spaces.

Remember to print a newline character at the end of the line.

It's a guarantee that the output will always be inside the range of -2147483648 ~ +2147483647.

Sample Input  Download

Sample Output  Download

Tags




Discuss