读入三个整数 a,b,c,按 (a+b)×c 直接输出结果。
OJ: roj
题目 ID: 1007
难度:入门
标签:输入输出python
创建: 2026-09-29 12:42
更新: 2026-10-04 22:22
题目描述
给定三个整数
思路
按题面括号顺序,先加后乘,一步输出结果。
参考代码
Python 版:
python
#!/usr/bin/env python3
# Author by Rainboy blog: https://rainboylv.com github: https://github.com/rainboylvx
# rbook: -> https://rbook.roj.ac.cn https://rbook2.roj.ac.cn
# rainboy的学习导航网站: https://idx.roj.ac.cn
# create_at: 2026-09-29 12:44
# update_at: 2026-09-29 12:44
import sys
def solve() -> None:
"""读入一行里的三个整数,输出表达式 (a+b)×c 的值。"""
a, b, c = map(int, sys.stdin.buffer.read().split())
print((a + b) * c)
if __name__ == "__main__":
solve()C++ 版(同一算法):
cpp
/**
* Author by Rainboy blog: https://rainboylv.com github: https://github.com/rainboylvx
* rbook: -> https://rbook.roj.ac.cn https://rbook2.roj.ac.cn
* rainboy的学习导航网站: https://idx.roj.ac.cn
* create_at: 2026-10-04 22:22
* update_at: 2026-10-04 22:22
*/
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll a, b, c;
// 读入三个整数,按 (a+b)*c 输出
cin >> a >> b >> c;
cout << (a + b) * c << "\n";
return 0;
}