首页 > 试题广场 >

牛牛学立体

[编程题]牛牛学立体
  • 热度指数:16049 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 256M,其他语言512M
  • 算法知识视频讲解
\hspace{15pt}给定一个长方体的长 a、宽 b 和高 c,请计算该长方体的表面积和体积。

【提示】
\hspace{15pt}对于不熟悉几何表面积、体积求法的同学,可以参考下面的公式:
\hspace{23pt}\bullet\,表面积:\displaystyle S = 2(ab + bc + ca)
\hspace{23pt}\bullet\,体积:\displaystyle V = abc

输入描述:
\hspace{15pt}在一行中输入三个整数 a,b,c \left(1 \leqq a,b,c \leqq 10^3\right),表示长、宽和高。


输出描述:
\hspace{15pt}第一行输出一个整数,表示表面积 S
\hspace{15pt}第二行输出一个整数,表示体积 V
示例1

输入

1 1 1

输出

6
1

说明

\hspace{15pt}在这个样例中:
\hspace{23pt}\bullet\,表面积:S = 2 \times (1\times 1 + 1\times 1 + 1\times 1) = 6
\hspace{23pt}\bullet\,体积:V = 1 \times 1 \times 1 = 1

备注:
本题已于下方时间节点更新,请注意题解时效性:
1. 2025-06-03 优化题面文本与格式。
2. 2025-06-05 优化题面文本与格式。
3. 2025-11-07 优化题面文本与格式,新增若干组数据。
#先记录长宽高
a, b, c = map(int, input().split())
#表面积
s = 2 * (a*b + b*c + c*a)
#体积
v = a*b*c
#这道题输出的时候错误,我之前尝试用换行符,但是print
#Python不能把整数 s 和 v 与字符串 '\n' 进行拼接( Python 不支持直接将整数和字符串用 + 连接,会导致 TypeError)
print(s)
print(v)
发表于 2025-12-19 14:58:02 回复(0)
a,b,c = map(int,input().split())
s = (a*b+b*c+c*a)*2
v = a*b*c
print(s)
print(v)

发表于 2025-11-09 22:26:07 回复(0)
a,b,c=map(int,input().split())
S=2*(a*b+b*c+c*a)
V=a*b*c
print("{}\n{}".format(S,V))
发表于 2025-10-31 08:42:28 回复(0)
a,b,c = map(int,input().split())

if a < 1:
    print("输入错误,1≦a")
    exit()
if c > 1000:
    print("输入错误,c≦1000")
    exit()
S = 2 * ((a * b) + (b * c) + (c * a))
V = a * b * c
print(S)
print(V)
发表于 2025-07-24 09:31:38 回复(0)
a, b, c = map(int, input().split())

S = 2 * (a*b + b*c + c*a)
V = a*b*c

print(f"{S}\n{V}")
发表于 2025-07-13 04:56:41 回复(0)
a,b,c = map(int,input().split())
print("%d\n%d"%(a*b*2+a*c*2+b*c*2,a*b*c))
发表于 2025-06-29 17:03:07 回复(0)
h,w,x = map(int,input().split())
print(int((h*w*2)+(h*x*2)+(w*x*2)),int(h*w*x),sep='\n')
发表于 2025-05-24 16:53:12 回复(0)