3333 - I2P(II)2026_Kuo_HW5 Scoreboard

Time

2026/05/12 15:30:00 2026/05/26 12:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
14948 Battle Hachimi
14309 Mixed Nuts

14948 - Battle Hachimi   

Description

You are on your way to attend Lab 5 of Introduction to Programming 2, and you saw a cat on the side of the road.

It noticed that you are late, and started singing to taunt you:

"Hachimi Chimichi, Ashiga Ga Ashi, MAMBOW! MAMBOW! MA-MAMBOOO, ting ting tung tung ting ting ting ting tung tung ting, HAAAAAAACHIMIIIIIII..."

You are furious, and decided to have a battle with the Hachimi cat. You take out your backpack, randomly pick up things and start throwing them at the cat. Each item hits differently — and some have special effects.

Each item has a use() which first calls damage(), then applies its effect. damage() checks if weight > defense — if so, it deals weight - defense damage to HP, otherwise it is blocked. The effect always applies after damage(), regardless of whether the hit was blocked. The battle ends early if Hachimi's HP reaches 0.

ID 0 — Laptop(int weight, int power) HP is lowered by power.

ID 1 — Notebook(int weight, int notes) Hachimi is scared of knowledge — defense is lowered by notes.

ID 2 — GPU(int weight) Hachimi feels heartbroken seeing an expensive GPU smashed — HP is lowered by current defense.

ID 3 — Shoe(int weight, int smell) The stench is unbearable — both HP and defense are reduced by smell.

Implement the constructor and use() for each derived class, as well as damage() on the base class Item. HP and defense cannot go below 0.

The constraints are as follows: 1 ≤ hp ≤ 1000, 1 ≤ defense ≤ 100, 1 ≤ n ≤ 50, 1 ≤ weight ≤ 50, 1 ≤ power ≤ 30, 1 ≤ notes ≤ 20, 1 ≤ smell ≤ 100.

Input

The first line contains hp, defense, and n. The following n lines each contain an item ID followed by its arguments.

Output

For each item, print the class name followed by hit or blocked, then on the next line print HP: <hp>, Defense: <defense>. Stop if Hachimi's HP reaches 0.

 
 
100 10 7
0 15 20           // Laptop, weight=15, power=20
1 12 4            // Notebook, weight=12, notes=4
2 20              // GPU, weight=20
1 5 3             // Notebook, weight=5 — blocked since weight < defense
3 18 5            // Shoe, weight=18, smell=5
0 20 30           // Laptop, weight=20, power=30 — Hachimi dies here
2 7               // GPU — never reached
 
 
Laptop hit
HP: 75, Defense: 10
Notebook hit
HP: 73, Defense: 6
GPU hit
HP: 53, Defense: 6
Notebook blocked
HP: 53, Defense: 3
Shoe hit
HP: 33, Defense: 0
Laptop hit
HP: 0, Defense: 0

Sample Input  Download

Sample Output  Download

Partial Judge Code

14948.cpp

Partial Judge Header

14948.h


Discuss




14309 - Mixed Nuts   

Description

Mixed nuts, especially peanuts, has always been Anya's favorite snack. They come in various shapes and sizes: cubes, cuboids, spheres, cones, and cylinders, each with their own unique taste and texture.

However, Anya got poor grades in her math class, and she struggles to acquire the Stella Stars needed for Loid's secret mission -- to get closer to Donovan Desmond and uncover his scheme.

To help Anya on her schoolwork, Loid decided to teach her the basics of geometry with the shapes of mixed nuts. Given several nuts of different shapes and sizes, Loid wants Anya to calculate total volume of the nuts. Since Anya has the ability to read other people's minds, she can easily read the volume formula for each shape straight from Loid's mind. However, she is not familiar with the calculations, so she needs your help to build a program that can calculate the volume of the nuts.

The volume of a nut can be calculated using the following formulas:

  • Cube: $V = s^3$, where $s$ is the side length of the cube.
  • Cuboid: $V = l \times w \times h$, where $l$, $w$, and $h$ are the length, width, and height of the cuboid, respectively.
  • Sphere: $V = \frac{4}{3} \pi r^3$, where $r$ is the radius of the sphere.
  • Cone: $V = \frac{1}{3} \pi r^2 h$, where $r$ is the radius of the base, and $h$ is the height of the cone.
  • Cylinder: $V = \pi r^2 h$, where $r$ is the radius of the base, and $h$ is the height of the cylinder.

Given a base class Nut, implement the derived classes CubeNut, CuboidNut, SphereNut, ConeNut, and CylinderNut that represent the shapes of mixed nuts. You should use setVolume to set the corresponding volume of each nut on construction.

Hints

  • Be careful that the type of volume is double, and 4/3=1 is of type int.
  • You only need to implement the constructor of each derived class.
  • Note that CubeNut inherits from CuboidNut instead of Nut.
  • Use oj::Nut::PI as your $\pi$ in the calculation.

Input

This is a partial judge problem, input and output are handled by main.cpp.

For each line of input, you will be given a string shape, followed by the corresponding parameters for the shape. The parameters are separated by a single space, and the order of the parameters is as follows:

  • Cube: $s$ (side length)
  • Cuboid: $l , w , h$ (length, width, height)
  • Sphere: $r$ (radius)
  • Cone: $r , h$ (radius, height)
  • Cylinder: $r , h$ (radius, height)

You should do some basic check: if the input is illegal (e.g. length < 0), then the volume should be 0. Also, you need to consider the scenario like Cuboid -1 -2 3, where volume would be 0 instead of 6.

Constraints

  • $\text{|s|, |l|, |w|, |h|, |r|} \leq 1000$
  • $\text{s, l, w, h, r}$ are presented in decimal format with at most 4 decimal places.
  • $0 \leq \text{# of shapes} \leq 1000$
  • Result is within the range of double.

Output

This is a partial judge problem, input and output are handled by main.cpp.

Output the total volume of the nuts, rounded to 4 decimal places.

Sample Input  Download

Sample Output  Download

Partial Judge Code

14309.cpp

Partial Judge Header

14309.h


Discuss