2517 - I2P(II)2022_Yang_hw4 Scoreboard

Time

2022/04/22 16:00:00 2022/05/06 13:20:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11417 String Operation
11443 3DShape
12767 The One Function and The Power Of Matrix
13487 Big Integer

11417 - String Operation   

Description

Given a set of strings, perform the operations according to the following commands, and output the final result of the given set of strings.

 

Commands:

s n m: Swap the nth string and the mth string.

i n m: Insert the mth string at the tail of the nth string.

si n m: Swap the specified strings first, and then insert.

is n m: Insert first, and then swap the two specified strings.

e: Exit.

 

Consider a set of strings:

ab

cd

ef

And a sequence of commands:

s 0 1

i 1 2

The result will be:

cd

abef

ef

 

You will be provided with main.cpp and function.h, and asked to implement function.cpp.

Input

The first line is an integer N indicating the number of input strings.

The following N lines each contains one input string.

Starting from the N+2th line will be a sequence of commands.

Output

Output the final result of the input strings.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11417.cpp

Partial Judge Header

11417.h

Tags




Discuss




11443 - 3DShape   

Description

Warning: You are not allowed to use malloc and free

Giving a bass-class Shape3D and 4 derived class : Sphere (球體), Cone (圓錐), Cuboid (長方體), Cube (立方體)

You need to calculate the volume of each shape.

PS:

V of Sphere: V = 4/3 π r3

V of Cone: V = 1/3 π r2 h

 

note : Remember to do some basic check, if the input is illegal (e.g.  length < 0, pi < 0 .....)  then the volume should be 0.

You don't need to consider the scenario like Cuboid -1 -2 3, volume would be 0 instead of 6.

Hint1: Be careful the type of volume is double.  4/3=1 (int),  so it should be 4.0/3.0

Hint2: You only need to implement the constructors.

Hint3: Note that Cube inherited Cuboid not Shape3D.

 

 

Input

There are only 4 shapes in this problem :

  • Sphere, following by its radius and pi. (e.g. Sphere 30 3.14)
  • Cone, following by its radius of bottom plane, height and pi. (e.g. Cone 3 100 3.14)
  • Cuboid, following by its length, width and height. (e.g. Cuboid 2 3 7)
  • Cube, following by its length. (e.g. Cube 2)

Output

Ouput the total volume of all the shapes.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11443.cpp

Partial Judge Header

11443.h

Tags




Discuss




12767 - The One Function and The Power Of Matrix   

Description

There is a function called "the one function",
the function is defined as:
F(N, M) = 1, if M <= N,
F(N, M) = F(N, M-1) + F(N, M - 2) + ... + F(N, M - N), if M > N

Given you N, M, tell the result of F(N, M) module 1000000009.

ouo.
Updated at: 2020/05/17 19:00, sorry for the typo in the description.

This is an exercise of operator overloading,
it is recommended that you can follow the partial judge code to finish your work.
There are 8 member functions and 1 additional function that you should implement.
Read the comments carefully to better understand the structure of the partial judge code.

You should choose 'c++11' as the option of submission.

For sample input 1,

N = 3, M = 5,
so F(3, 1) = F(3, 2) = F(3, 3) = 1,
and F(3, 4) =  F(3, 3) + F(3, 2) + F(3, 1) = 3
and F(3, 5) = F(3, 4) + F(3, 3) + F(3, 2) = 5
and F(3, 5) % 100000009 = 5,
so the output must be 5.

Input

The input contains 1 line,
the first line contains 2 numbers N, M.

It is guaranteed that:
1 <= N <= 100
1 <= M <= 10^9

Output

The output contains 1 line.

Output the answer of F(N, M), and a newline character at the end of line.

Sample Input  Download

Sample Output  Download

Partial Judge Code

12767.cpp

Partial Judge Header

12767.h

Tags




Discuss




13487 - Big Integer   

Description

In C and C++, an integer (int) is represented by 32 bits, which has the range of [-231, 231-1]=[-2147483648, 2147483647]. However,  some high level language such as Python can handle arbitrarily large numbers. In this problem, you are asked to design a class called INT with the following constrains and features:

  1. Stores an unsigned integer within the range of [0, 101000)
  2. Overload the operator + to support addition without using traditional function.
  3. Overload the operator = to copy the data
  4. Overload the operator >> and << to support cin and cout.

The idea of overloading operators is to operate your class like existing data type such as int.

The following is a sample code of using the class. For more details, please refer to main.cpp and function.h.

INT a, b, c;
cin >> a;
cin >> b;
c = a + b;
cout << c << endl;
// Input:
123123123123123123123123123123
987654321
987654321987654321987
// Output:
1110777445110777445110777445110

Input

There are two lines. Each line has a single integer.

No leading 0's are given in the test cases. E.g. 0001239487. 

The length of the integer is at most 1000 characters.

Output

Compute and output the sum of the two integers.

Sample Input  Download

Sample Output  Download

Partial Judge Code

13487.cpp

Partial Judge Header

13487.h

Tags




Discuss