欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1850E.Cardboard for Pictures
Cardboard for Pictures
Mircea has pictures. The -th picture is a square with a side length of centimeters.
He mounted each picture on a square piece of cardboard so that each picture has a border of centimeters of cardboard on all sides. In total, he used square centimeters of cardboard. Given the picture sizes and the value , can you find the value of ?
A picture of the first test case. Here , so is the answer.
Please note that the piece of cardboard goes behind each picture, not just the border.
Input
The first line contains a single integer () — the number of test cases.
The first line of each test case contains two positive integers () and () — the number of paintings, and the amount of used square centimeters of cardboard.
The second line of each test case contains space-separated integers () — the sizes of the paintings.
The sum of over all test cases doesn't exceed .
Additional constraint on the input: Such an integer exists for each test case.
Please note, that some of the input for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
Output
For each test case, output a single integer — the value of () which was used to use exactly squared centimeters of cardboard.
Note
The first test case is explained in the statement.
For the second test case, the chosen was , thus the only cardboard covers an area of squared centimeters.
For the third test case, the chosen was , which obtains the covered area $c = (2 \cdot 4 + 2)^2 \times 5 = 10^2 \times 5 = 100 \times 5 = 500$ squared centimeters.
Samples
10
3 50
3 2 1
1 100
6
5 500
2 2 2 2 2
2 365
3 4
2 469077255466389
10000 2023
10 635472106413848880
9181 4243 7777 1859 2017 4397 14 9390 2245 7225
7 176345687772781240
9202 9407 9229 6257 7743 5738 7966
14 865563946464579627
3654 5483 1657 7571 1639 9815 122 9468 3079 2666 5498 4540 7861 5384
19 977162053008871403
9169 9520 9209 9013 9300 9843 9933 9454 9960 9167 9964 9701 9251 9404 9462 9277 9661 9164 9161
18 886531871815571953
2609 10 5098 9591 949 8485 6385 4586 1064 5412 6564 8460 2245 6552 5089 8353 3803 3764
1
2
4
5
7654321
126040443
79356352
124321725
113385729
110961227
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |