2219 - I2P(I)2020_Hu_lab9 Scoreboard

Time

2020/12/21 18:30:00 2020/12/21 20:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
13066 Complex Number Structure
13067 Queen of banana milk kingdom 2

13066 - Complex Number Structure   

Description

This is a partial judge problem.
In this problem, you're asked to implement the following function that related to complex number arithmetic.

typedef struct {
	long long real;
	long long imag; 
} Complex;

First you have a struct binded with two integers which is the real part and imaginary part of a complex number. 

Complex CreateComplex(long long, long long);

Return a complex number that its real part is the first parameter and its imaginary part is the second parameter. 

Complex Add(Complex, Complex);
Complex Sub(Complex, Complex);
Complex Mul(Complex, Complex);

For the above three functions, you have to return the result of doing the corresponding calculation.
Add stands for addition, Sub stands for subtraction, Mul stands for Multiplication.

void Compare(Complex*, Complex*);

For the above function, we compare the absolute value of two complex number. If the absolute value of the first parameter is less than the absolute value of the second parameter, swap them. That it, after executing Compare() function, guarentee that the first parameter has the greater absolute value, and if the absolute value are the same, do nothing.

For more information, you can refer to the source code.

Note:

Addition Rule: (a + bi) + (c + di) = (a + c) + (b + d)i
Subtraction Rule: 
(a + bi) - (c + di) = (a - c) + (b - d)i
Multiplication Rule: (a + bi) · (c + di) = (ac - bd) + (cb + ad)i

 

Input

First line of the input contains one integer T (T <= 100000), representing the number of operation.
Next, input T lines. Each line contains one integer and two complex numbers.
The integer indicates which function to use.
Guarentee the real and imag of the input complex number are integers and they're in range of [-1000000, 1000000] .
For detail input format, you can refer to the source code.

Output

Output the calculation result for each operation.

Sample Input  Download

Sample Output  Download

Partial Judge Code

13066.c

Partial Judge Header

13066.h

Tags




Discuss




13067 - Queen of banana milk kingdom 2   

Description

Yazmonkey is the King of the banana milk kingdom. He got everything he wants except a wife. So he host a wife-chosen ceremony, he wants to choose the richest monkey among all candidates, which means he will choose the monkey who possesses the most banana milk.
You're asked to help Yazmonkey to complete the code in order to successfully select the best choice. What you have to implement is as follow.

typedef struct {
	int num; 
	char* name; 
} Monkey;

First you have a structure of monkey, num represents the amount of banana milk it possess.

Monkey* CreateMonkeyArray(int);

You should return a pointer points to the Monkey array with length equal to the parameter.

void SetVal(Monkey*, int, int, char[]);

Set the value of the index of second parameter of the Monkey array as the last two parameter.
Be caution that main.c has already malloc the char array to store the input string.

int Compare(Monkey*, int, int);

Return 1 if the index of third parameter of the Monkey array have a higher priority than the index of second parameter of the Monkey array.

void Swap(Monkey*, int, int);

 Swap the value in the Monkey array.

void FreeMonkeyArray(Monkey*, int);

Free the Monkey array with length equal to the parameter. 
If you think the above description is not clear, you should trace the sorce code for detailed.

 

Input

First line of the input contains one integer T, (T <= 10) indicates the number of testcases.
For each testcase, first input an integer N, (N <= 50), representing the number of candidates.

Next, Input contains N lines. In i-th line, it contains one integer Ki, (1 <= K<= 50) and one string S, (|S| <= 100000) which reprecenting the number of cartons of banana milks the i-th candidate has and the name of the monkey.
Guarentee that there's no two monkey has the same name.

Output

Output the order of the candidates sorted by the number of banana milk in decending order. If two candidates have the same amount of the banana milk, them sort it by the contray of lexicographic order.

 

Sample Input  Download

Sample Output  Download

Partial Judge Code

13067.c

Partial Judge Header

13067.h

Tags




Discuss