hiho week 148 register

Ended

Participants:382

Verdict:Accepted
Score:100 / 100
Submitted:2017-05-01 15:46:36

Lang:Java

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
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        while (s-- > 0) {
            int n = sc.nextInt();
            int p = sc.nextInt();
            int w = sc.nextInt();
            int h = sc.nextInt();
            int[] ps = new int[n];
            for(int i=0;i<n;i++){
                ps[i= sc.nextInt();
            }
            System.out.println(solve(npwh,ps));
        }
    }
    static int solve(int nint pint wint h,int[] ps) {
        int sum = 0;
        for(int i=0;i<n;i++){
            sum+=ps[i];
        }
        int countPerPage = sum/p;
        int size = (int)Math.sqrt((w*h*1.0)/countPerPage);
        for(int i=size;i>=0;i--){
            if(check(npwhpsi)){
                return i;
            }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX