CF1801F.Another n-dimensional chocolate bar
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Mom bought the boy Vasya a n -dimensional chocolate bar, which is a n -dimensional cube with the length of each side equal to 1 . The chocolate is planned to be divided into slices. According to the i th dimension, it can be divided by hyperplanes into ai equal parts. Thus, the chocolate is divided in total into a1⋅a2⋅a3⋅…⋅an slices, each slice has a length of i -th dimension equal to ai1 , respectively, the volume of each slice is a1a2⋯an1 .Vasya and his friends want to cut a chocolate bar to get at least k pieces, while Vasya wants to maximize the volume of the smallest of them. It is possible to cut the chocolate bar only at the junction of the lobules, and each incision must pass through the entire chocolate bar along some hyperplane involved in the formation of lobules. Only after making all the cuts, Vasya disassembles the chocolate into pieces.
More formally, Vasya wants to choose the numbers b1,b2,…,bn ( 1≤bi≤ai ) — the number of parts into which Vasya will cut the chocolate bar along each dimension. The condition b1⋅b2⋅…⋅bn≥k must be met to get at least k pieces after all cuts. It can be noted that with optimal cutting with such parameters, the minimum piece will contain ⌊b1a1⌋⋯⌊bnan⌋ slices, and its volume will be equal to ⌊b1a1⌋⋯⌊bnan⌋⋅a1a2⋯an1 .
Vasya wants to get the maximum possible value of the volume of the minimum piece multiplied by k , that is, he wants to maximize the number of ⌊b1a1⌋⋯⌊bnan⌋⋅a1a2⋯an1⋅k . Help him with this.
输入格式
The first line contains two integers n and k (1≤n≤100 , 1≤k≤107) — the dimension of the chocolate bar, and how many parts it needs to be divided into.
The second line contains n integers a1, a2, …, an (1≤ai≤107) — the number of pieces on which the chocolate is placed along each of the dimensions.
输出格式
Print one number — the maximum possible volume of the smallest of the obtained pieces, multiplied by k , with an absolute or relative error of no more than 10−9 .
If it is impossible to cut a chocolate bar into at least k pieces under the given restrictions, output 0 .
输入输出样例
输入#1
1 2 5
输出#1
0.8
输入#2
2 6 5 10
输出#2
0.72
输入#3
2 7 4 4
输出#3
0.875
输入#4
2 3 4 5
输出#4
0.75
输入#5
4 444 57 179 239 2
输出#5
0.97557326850704739751
输入#6
2 5 2 2
输出#6
0
说明/提示
In the first example, a one – dimensional chocolate bar can be divided as follows:
Then the answer will be 52⋅2=0.8
In the second example, the chocolate bar can be cut as follows:
Then the answer will be 52⋅103⋅6=0.72
In the third example, the chocolate bar can be cut as follows:
Then the answer will be 42⋅41⋅7=0.875