308166: CF1476B. Inflation

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Inflation

题意翻译

你手上有一个长度为 $n$ 的序列 $p=[p_0,p_1,...,p_{n-1}]$ 表示一个产品 $n-1$ 个月的价格变化,其中 $p_0$ 为初始价格,而 $p_i(i>0)$ 表示第 $i$ 月上涨的价格。 我们规定这个产品第 $i$ 月的“通货膨胀率”为该产品第 $i$ 月上涨的价格与该产品第 $i-1$ 月的价格之比,即 $\dfrac{p_i}{\sum_{j=1}^{i-1}p_j}\times100\%$ 的值。 你的老板当然不希望“通货膨胀率”过高,因此他限定了一个阈值 $k$ 表示对这个产品,**任意一个月**的“通货膨胀率”都不超过 $k\%$,于是你需要改动序列 $p$,你可以对序列的任意元素增加任意一个正整数。 但是因为改动的太厉害会使账务出现问题,所以你要求出使序列 $p$ 满足你的老板的要求所需增加的数值之和的最小值。$T$ 组询问。 $1\leq T\leq10^3;2\leq n\leq100,1\leq k\leq100;1\leq p_i\leq10^9;$

题目描述

You have a statistic of price changes for one product represented as an array of $ n $ positive integers $ p_0, p_1, \dots, p_{n - 1} $ , where $ p_0 $ is the initial price of the product and $ p_i $ is how the price was increased during the $ i $ -th month. Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase $ p_i $ to the price at the start of this month $ (p_0 + p_1 + \dots + p_{i - 1}) $ . Your boss said you clearly that the inflation coefficients must not exceed $ k $ %, so you decided to increase some values $ p_i $ in such a way, that all $ p_i $ remain integers and the inflation coefficients for each month don't exceed $ k $ %. You know, that the bigger changes — the more obvious cheating. That's why you need to minimize the total sum of changes. What's the minimum total sum of changes you need to make all inflation coefficients not more than $ k $ %?

输入输出格式

输入格式


The first line contains a single integer $ t $ ( $ 1 \le t \le 1000 $ ) — the number of test cases. The first line of each test case contains two integers $ n $ and $ k $ ( $ 2 \le n \le 100 $ ; $ 1 \le k \le 100 $ ) — the length of array $ p $ and coefficient $ k $ . The second line of each test case contains $ n $ integers $ p_0, p_1, \dots, p_{n - 1} $ ( $ 1 \le p_i \le 10^9 $ ) — the array $ p $ .

输出格式


For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than $ k $ %.

输入输出样例

输入样例 #1

2
4 1
20100 1 202 202
3 100
1 1 1

输出样例 #1

99
0

说明

In the first test case, you can, for example, increase $ p_0 $ by $ 50 $ and $ p_1 $ by $ 49 $ and get array $ [20150, 50, 202, 202] $ . Then you get the next inflation coefficients: 1. $ \frac{50}{20150} \le \frac{1}{100} $ ; 2. $ \frac{202}{20150 + 50} \le \frac{1}{100} $ ; 3. $ \frac{202}{20200 + 202} \le \frac{1}{100} $ ; In the second test case, you don't need to modify array $ p $ , since the inflation coefficients are already good: 1. $ \frac{1}{1} \le \frac{100}{100} $ ; 2. $ \frac{1}{1 + 1} \le \frac{100}{100} $ ;

Input

题意翻译

你手上有一个长度为 $n$ 的序列 $p=[p_0,p_1,...,p_{n-1}]$ 表示一个产品 $n-1$ 个月的价格变化,其中 $p_0$ 为初始价格,而 $p_i(i>0)$ 表示第 $i$ 月上涨的价格。 我们规定这个产品第 $i$ 月的“通货膨胀率”为该产品第 $i$ 月上涨的价格与该产品第 $i-1$ 月的价格之比,即 $\dfrac{p_i}{\sum_{j=1}^{i-1}p_j}\times100\%$ 的值。 你的老板当然不希望“通货膨胀率”过高,因此他限定了一个阈值 $k$ 表示对这个产品,**任意一个月**的“通货膨胀率”都不超过 $k\%$,于是你需要改动序列 $p$,你可以对序列的任意元素增加任意一个正整数。 但是因为改动的太厉害会使账务出现问题,所以你要求出使序列 $p$ 满足你的老板的要求所需增加的数值之和的最小值。$T$ 组询问。 $1\leq T\leq10^3;2\leq n\leq100,1\leq k\leq100;1\leq p_i\leq10^9;$

加入题单

算法标签: