簡単 1件解決済み 正答率100.0%

Rectangle Perimeter

Compute the perimeter of a rectangle from its sides.

問題

A rectangle has two sides of length width and two sides of length height. Its perimeter is the total length of all four sides.

Implement rectangle_perimeter(width, height).

Input

width: The width of the rectangle. height: The height of the rectangle.

Output

Return the perimeter as an integer.

制約

1 ≤ width, height ≤ 1,000,000

例

例 1
入力:
width = 3
height = 5

期待される出力:
expected = 16
入力:
long long width = 3;
long long height = 5;

期待される出力:
long long expected = 16;
入力:
long width = 3;
long height = 5;

期待される出力:
long expected = 16;

解説

Two sides of 3 and two sides of 5: 3 + 3 + 5 + 5 = 16.

例 2
入力:
width = 7
height = 7

期待される出力:
expected = 28
入力:
long long width = 7;
long long height = 7;

期待される出力:
long long expected = 28;
入力:
long width = 7;
long height = 7;

期待される出力:
long expected = 28;

解説

A square is a rectangle too: 4 × 7 = 28.

参考資料

この課題はCodeUtility用に調整されています。上記の説明と制約に従ってください。

他の人の解答から学ぶ

コミュニティの解答

ネタバレ注意:下に1件の全解答あり まずは自分で挑戦してみましょう。他の開発者のコードやAIレビューも見ることができます。 サインインして課題を解くと議論に参加できます。