| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 9144 | Factorials |
|
| 9148 | Matrix Multiplication |
|
| 9152 | Stable Sort |
|
| 9156 | Robot Move |
|
| 9160 | PNPOLY |
|
Description
Calculate N! = 1 × 2 × ... × (N - 1) × N. Note that the number may exceed the range of primitive integer type. A data structure should be maintained to store the computed results.
Input
There are multiple test cases in each data set. Each test case contains a single integer denoting N (1 ≤ N ≤ 500) in a line. The input is terminated by end-of-file.
Output
For each given N, output the value of N! in a line.
Technical Specification
For data set #1, 1 ≤ N ≤ 20.
For data set #2, 1 ≤ N ≤ 50.
For data set #3, 1 ≤ N ≤ 200.
For data set #4, 1 ≤ N ≤ 500.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Compute C = A × B, where A, B and C are matrices of size n × m, m × p, and n × p, respectivily.
Input
There are multiple test cases in each data set. Each case begins with a line of three integers n, m and p, which denote the dimensions of the matrices defined in the problem description. Each of the following n lines contains m integers aij, representing the elements in matrix A, and then m lines of p integers bij, representing the elements in matrix B. There is a blank line between two successive test cases, and the input is terminated by end-of-file.
Output
For each test case, output n lines of p integers representing the elements of matrix C. Add a single space to seperate two successive elements in the same line (please do not output extra leading or trailing space characters). Output a blank line after each matrix.
Technical Specification
For data set #1, 1 ≤ n, m, p ≤ 5 and |aij|, |bij| ≤ 5.
For data set #2, 1 ≤ n, m, p ≤ 20 and |aij|, |bij| ≤ 500.
For data set #3, 1 ≤ n, m, p ≤ 50 and |aij|, |bij| ≤ 2000.
For data set #4, 1 ≤ n, m, p ≤ 100 and |aij|, |bij| ≤ 10000.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Given the grades of N people.
Output the sorted result in ascending order.
Hint: Ascending order is an order of sorting that starts with the lowest value and proceeds to the highest value
Input
The first line of input contains a positive integer t , which indicates the number of test cases.
In each test case, the first line contains one integer N.
The following N lines specify the name Si and the grade Gi.
t <= 60
1 <= |Si| <= 7
0 <= Gi <= 100 (Gi is an integer.)
test case 1: 1 <= N <= 103
test case 2: 1 <= N <= 104
test case 3: 1 <= N <= 105
test case 4: 1 <= N <= 5*106
Output
Output the result in N lines. Every line contains the name and the grade. If more people’s grades are same, output by input order. (That means it uses stable sort.)
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Consider a sequence of N different numbers. The operation "MOVE X Y" moves all the numbers in front of X (including X) and then inserts them in front of Y without changing order.
Given an initial sequence and a target sequence, generate a series of operations that can convert the initial sequence into the target sequence. Moreover, after each move, print the current position of the number 1. For example, if the initial sequence is 1 2 3 4 5, and the target sequence is 1 4 3 2 5, a possible series of operations could be
MOVE 2 4
2
MOVE 2 5
3
MOVE 3 2
1
(The solution is not unique. The answer is considered correct as long as the operations can generate the target sequence. But, in each input, total moves will not exceed 10001.)
Input
There are several inputs. We simplified this problem. First, there is a positive integer N which determines how many numbers in the target sequence and the initial sequence is from 1 to N. Next, there are N integers for the target sequence. In the target sequence, each integer is unique and is between 1 and N. At the end of file, N is zero.
test case 1: N <= 10
test case 2: N <= 100
test case 3: N <= 1000
test case 4: N <= 10000
Output
For each output, first, please print the input target sequence in one line and each number is separated by one space. Second, print how many moves in your total operation in one line without spaces. If it is impossible moving to the target, please print -1. Then, for each move, print "MOVE X Y" mentioned in problem description in one line and after "MOVE" there is only one space and between two numbers is only one space, too. Finally, print the position of 1 in each move in one line without spaces.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Given a 2D point, answer if the point is inside a simple 2D polygon of N vertices?
Note that points lie on the vertices or edges of polygon are not considered inside.
Input
The first line is an integer t which indicates the number of test cases.
For each case, the first line is an integer N that denotes the number of vertices of a polygon followed by a list of n pairs of vertices' 2D coordinates (x, y) in counter-clockwise order. All vertices on the polygon are in the rectangle [-20000, 20000]x[-20000,20000].
The next line is an integer q(1 <= q <= 100) indicates the number of test point followed by a list of q pairs of points' 2D coordinates. The bound of x and y coordinate of query points is between -106 and 106.
Size of each data:
Data set 1: N <= 100
Data set 2: N <= 100
Data set 3: N <= 10000
Data set 4: N <= 10000
Output
The output is a line with 'Yes' if the test point is inside the polygon, otherwise output a line with 'No'(without quote).