CF1801F.Another n-dimensional chocolate bar
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:512MB
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 ith 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.
妈妈给男孩瓦夏买了一块 n 维巧克力,它是一个边长为 1 的 n 维立方体。这块巧克力计划被切割成若干片。在第 i 个维度上,可以通过超平面将其均分为 ai 份。因此,整块巧克力最终被分割为 a1⋅a2⋅a3⋅…⋅an 片,每片在第 i 个维度上的长度为 ai1,其体积为 a1a2⋯an1。
瓦夏和他的朋友们希望将巧克力切出至少 k 块,而瓦夏希望使其中最小一块的体积尽可能大。巧克力只能沿小块(lobule)之间的接缝处切割,且每次切割必须沿某个参与构成小块的超平面,贯穿整块巧克力。所有切割完成后,瓦夏才将巧克力拆分为独立的块。
更形式化地,瓦夏需选择整数 b1,b2,…,bn(满足 1≤bi≤ai),表示他在每个维度上将巧克力切分为多少份。为确保最终得到至少 k 块,必须满足条件 b1⋅b2⋅…⋅bn≥k。可以注意到,在按这些参数进行最优切割时,最小的一块将恰好包含 ⌊b1a1⌋⋯⌊bnan⌋ 个小片,其体积为 ⌊b1a1⌋⋯⌊bnan⌋⋅a1a2⋯an1。
瓦夏希望最大化最小块的体积乘以 k,即最大化数值
⌊b1a1⌋⋯⌊bnan⌋⋅a1a2⋯an1⋅k.
请帮助他实现这一目标。
输入格式
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.
第一行包含两个整数 n 和 k(1≤n≤100,1≤k≤107)—— 分别表示巧克力块的维度,以及需要将其分割成的部分数。
第二行包含 n 个整数 a1, a2, …, an(1≤ai≤107)—— 表示巧克力在各个维度上被划分出的小块数量。
输出格式
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.
输出一个数字——在满足限制条件的前提下,所能得到的各块巧克力中体积最小者所能达到的最大体积,再乘以 k,要求绝对或相对误差不超过 10−9。
若在给定限制条件下无法将巧克力切成至少 k 块,则输出 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
在第一个例子中,一个一维巧克力棒可以如下分割:

则答案为 52⋅2=0.8。
在第二个例子中,巧克力棒可以如下切割:

则答案为 52⋅103⋅6=0.72。
在第三个例子中,巧克力棒可以如下切割:

则答案为 42⋅41⋅7=0.875。
输入解题思路,AI测评打分。不知道怎么写?