hiho week 148 register

Ended

Participants:382

Verdict:Accepted
Score:100 / 100
Submitted:2017-05-03 23:25:41

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<math.h>
using namespace std;
int main(void)
{
    int m,n,p,w,h;
    int a[1001];
    int ans,i,j,numline,perline,sumch,perch,perpage,sumline;
    int flag;
    cin>>m;
    for(i=0;i<m;i++)
    {
        cin>>n>>p>>w>>h;
        sumch=0;
        for(j=0;j<n;j++)
        {
            cin>>a[j];
            sumch=sumch+a[j];
        }
        perch=sumch/p;
        ans=int(sqrt(double(w*h)/double(perch)))+1;
        ans++;
        flag=1;
        while(flag==1)
        {
            numline=0;
            ans--;
            perline=w/ans;
            perpage=h/ans;
            sumline=perpage*p;
            for(j=0;j<n;j++)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX