`eat` is the number of minutes that your guests will spend on eating. solve(p, eat) is to calculate the minimum number of minutes that is required to divide the pancakes such that each plate contains no more than `eat` pancakes.
To divide a plate of K pancakes into some plates that each contains no more than `eat` pancakes, you need at least (K - 1) / `eat` minutes. Parker On Tue, Apr 14, 2015 at 7:27 PM puneet Chaturvedi <[email protected]> wrote: > Hi just checked out solution for " Infinite house of pancakes" from > webasite "go-hero.net". > > I am able to get the purpose of " for loop" for 1000 times with variable > "eat". > > Below is the code: > ============================================ > public class B { > > public static void main(String[] args) { > Scanner sc = new Scanner(System.in); > int T = sc.nextInt(); > for (int t = 1; t <= T; t++) { > int D = sc.nextInt(); > int[] p = new int[D]; > for (int i = 0; i < D; i++) > p[i] = sc.nextInt(); > int best = 1000; > for (int eat = 1; eat <= 1000; eat++) { > int time = solve(p, eat); > best = Math.min(time, best); > } > > System.out.printf("Case #%d: %d\n", t, best); > } > } > > private static int solve(int[] p, int eat) { > int special = 0; > for (int i = 0; i < p.length; i++) > special += (p[i] - 1)/eat; > return special + eat; > } > > } > > -- > You received this message because you are subscribed to the Google Groups > "Google Code Jam" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-code/0a643489-605a-401f-8adc-5832f07a9d88%40googlegroups.com > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/CAGDEU-%2BfoByTtsRBBvsteoXqpC87aQ8HuqWJ3gr%2BLn1U81qgtA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
