#K4226. Volume Calculation for Cube and Triangular Prism

    ID: 27048 Type: Default 1000ms 256MiB

Volume Calculation for Cube and Triangular Prism

Volume Calculation for Cube and Triangular Prism

You are given a shape type and its corresponding dimensions. The first number in the input represents the choice of the shape. If the choice is 1, it represents a cube and is followed by one integer C which is the length of the cube's edge. The volume of the cube is given by the formula:

\(V = C^3\)

If the choice is 2, it represents a triangular prism and is followed by three integers A, B, and H. Here, the area of the triangular base is computed as:

\(\text{Area} = \frac{1}{2} \times A \times H\)

and the volume of the triangular prism is:

\(V = \text{Area} \times B\)

If the shape type is neither 1 nor 2, output None.

Read the input from standard input (stdin) and print the result to standard output (stdout).

inputFormat

The input consists of a single line containing one or more space-separated numbers. The first number is an integer representing the shape type (1 for cube, 2 for triangular prism). For a cube, the next number is the edge length (an integer). For a triangular prism, the next three numbers represent A, B, and H respectively.

Examples:

  • 1 3 represents a cube with edge length 3.
  • 2 4 5 6 represents a triangular prism with dimensions A=4, B=5, H=6.

outputFormat

Print the volume of the shape. For a cube, the volume is an integer. For a triangular prism, the volume may be a decimal number. If the input is invalid (i.e. shape type is not 1 or 2), print None (without quotes).

## sample
1 3
27