## 描述

Steven loves reading book on his phone. The book he reads now consists of N paragraphs and the i-th paragraph contains ai characters.

Steven wants to make the characters easier to read, so he decides to increase the font size of characters. But the size of Steven's phone screen is limited. Its width is W and height is H. As a result, if the font size of characters is S then it can only show ⌊W / S⌋ characters in a line and ⌊H / S⌋ lines in a page. (⌊x⌋ is the largest integer no more than x)

So here's the question, if Steven wants to control the number of pages no more than P, what's the maximum font size he can set? Note that paragraphs must start in a new line and there is no empty line between paragraphs.

## 输入

Input may contain multiple test cases.
The first line is an integer TASKS, representing the number of test cases.
For each test case, the first line contains four integers N, P, W and H, as described above.
The second line contains N integers a1, a2, ... aN, indicating the number of characters in each paragraph.

For all test cases,
1 <= N <= 103,
1 <= W, H, ai <= 103,
1 <= P <= 106,

There is always a way to control the number of pages no more than P.

## 输出

For each testcase, output a line with an integer Ans, indicating the maximum font size Steven can set.

2
1 10 4 3
10
2 10 4 3
10 10

3
2

## 实现代码 C++

#include<iostream>
#include<cstring>

using namespace std;

int paragraphs[1000000+5];
int n,p,w,h;
int maxn;

int calLines(int char_each_line){
int total = 0;
for( int i = 0 ; i < n ; i ++ ){
total += paragraphs[i] / char_each_line;
if( paragraphs[i] % char_each_line != 0){
total ++;
}
}
}

void solve(){
int min = (w>h)?h:w;
int currentS = 1;
while(currentS <= min){
int char_each_line = w/currentS;
int lines_each_page = h/currentS;
int needLines = calLines(char_each_line);
int pages = needLines / lines_each_page;
if(needLines%lines_each_page!=0){
pages++;
}
if( pages <= p && currentS > maxn ){
maxn = currentS;
}
currentS ++;
}
}

int main(){
int caseNumber = 0;
cin >> caseNumber;
int currentCase = 0;
while (currentCase < caseNumber) {
maxn = 0;
cin>>n>>p>>w>>h;
for(int i = 0 ; i < n ; i ++){
cin>>paragraphs[i];
}
solve();
cout<<maxn<<endl;
currentCase ++;
}
return 0;
}
{"ft_lang_label":"__label__en","ft_lang_prob":0.73701483,"math_prob":0.9936798,"size":2341,"snap":"2019-43-2019-47","text_gpt3_token_len":743,"char_repetition_ratio":0.12451861,"word_repetition_ratio":0.04784689,"special_character_ratio":0.3126869,"punctuation_ratio":0.1707819,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97577447,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-11-12T11:09:12Z\",\"WARC-Record-ID\":\"<urn:uuid:25ed09f3-6069-4701-982f-95d8c228b9a1>\",\"Content-Length\":\"37433\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:18c41deb-0800-4c3d-8f11-07759f2ad6ed>\",\"WARC-Concurrent-To\":\"<urn:uuid:30ba3bed-5f0c-4b46-99b8-e533e74d1a7a>\",\"WARC-IP-Address\":\"47.100.103.105\",\"WARC-Target-URI\":\"http://oushaobin.cn/archives/microsoft-2016-intern-font-size.html\",\"WARC-Payload-Digest\":\"sha1:XHGQDKPMJEJNHF72EMTUP6SMWZR4SNQI\",\"WARC-Block-Digest\":\"sha1:KITFYTVSS37SCON4IB7RMMEIAWKMSPOH\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-47/CC-MAIN-2019-47_segments_1573496665521.72_warc_CC-MAIN-20191112101343-20191112125343-00213.warc.gz\"}"}