PROBLEM 8
Easy

Rectangle Perimeter

Programming Basics · C++

</>
STATUS Not solved

TASK

Problem

#8

In “Rectangle Perimeter”, given two integers `a` and `b`, treat them as side lengths and print the perimeter.

EXAMPLE

Example

Input
3 5
Output
16

LIMITS

Constraints

1 ≤ a, b ≤ 10^9. The result fits in a signed 64-bit integer.
📖
LEARN Theory for this problem
+

Use `long long` for integer arithmetic when products may exceed 32-bit `int`.

Connection to “Rectangle Perimeter”: here, intermediate values are best kept in named variables so the formula stays readable and data types remain clear.

💡
NEED HELP? Hints
+

['Read both values, compute the requested expression, then print only the result.', 'After solving “Rectangle Perimeter”, verify the algorithm on your own small example and on an allowed boundary case. Print only the required result with no extra text.']

ANSWER Solution
+
#include <iostream>
using namespace std;
int main() {
    long long a, b;
    cin >> a >> b;
    long long result = 2 * (a + b);
    cout << result << '\n';
    return 0;
}