PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000298. Bìa cứng cho tranh (Cardboard for Pictures)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Bìa cứng cho tranh (Cardboard for Pictures)
Cardboard for Pictures
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are square pictures, with side lengths cm. Each is mounted on square cardboard with a uniform border of width cm on every side, including cardboard behind the picture. The total cardboard area is square cm. A positive integer is guaranteed to exist; find it.
Input
First line: . Second line: integers .
Output
Print the positive integer .
Subtasks
- Subtask 1 (20 points): ; ; ; a positive integer solution exists.
- Subtask 2 (30 points): ; ; ; ; a positive integer solution exists.
- Subtask 3 (50 points): ; ; ; a positive integer solution exists.
Examples
Input 1
3 50
3 2 1
Output 1
1
Explanation
Cardboard sides are 5,4,3; the total area is 25+16+9=50.
Input 2
1 100
6
Output 2
2
Explanation
The cardboard side is 6+2×2=10.