// cloudMichael.java // Word Cloud, MCPC 2014, Problem E // Java Version translated from Michael Goldwasser C++ version by R. Pilgrim import java.io.*; import java.util.Scanner; public class cloudMichael { public static long PAD = 10l; // interspace padding public static int MIN_C = 5; public static int MAX_C = 1000; public static int MAX_W = 5000; public static int MAX_N = 1000; public static item[] box = new item[MAX_N]; public static void main(String[] args)throws FileNotFoundException { FileReader reader = new FileReader("cloud.in"); Scanner in = new Scanner(reader); int trial=0; while (true) { int W = in.nextInt(); int N = in.nextInt(); if (W == 0) break; String toss = in.nextLine(); if (W>MAX_W) System.err.println("ILLEGAL W"); if (N>MAX_N) System.err.println("ILLEGAL N"); int maxC = 0; String prev = ""; for (int j=0; jMAX_C) System.err.println("ILLEGAL C"); if ((S.compareTo(prev))<0) System.err.println("WARNING: NOT ALPHABETIZED"); prev = S; // for style only box[j] = new item(); box[j].wordlength = S.length(); box[j].count = C; maxC = Math.max(maxC, C); } for (int j=0; j W) System.err.println("WORD TOO LONG"); } int total = 0; int lineWidth = box[0].width; int lineHeight = box[0].height; for (int j=1; j 0) return (num/denom + 1); else return (num/denom); } } class item { int wordlength,count,width,height; }