1052 - I2P CS 2016 Chen HW6 Scoreboard

Time

2016/10/29 16:00:00 2016/11/03 12:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10766 Shell Game
11159 Aliquot sum

10766 - Shell Game   

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 is 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

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

10401Contest



Discuss




11159 - Aliquot sum   

Description

In mathematics, the aliquot sum s(n) of a positive integer n is the sum of all positive proper divisors of n. A positive proper divisor is a positive divisor of a number n, excluding n itself. The aliquot sums of perfect, deficient, and abundant numbers are equal to, less than, and greater than the number itself respectively.

 

If s(n) > n, then n is an abundant number.

If s(n) < n, then n is a deficient number.

If s(n) = n, then n is a perfect number.

 

Given a positive integer n, please calculate the aliquot sum and find out which kind of number is it.

 

For example, the proper divisors of 15 (that is, the positive divisors of 15 that are not equal to 15) are 1, 3 and 5, so the aliquot sum of 15 is 9 (1 + 3 + 5), and 15 will be a deficient number.

Input

A positive integer n.

Output

If n is an abundant number, output A.

If n is a deficient number, output D.

If n is a perfect number, output P.

Sample Input  Download

Sample Output  Download

Tags




Discuss