@@ -0,0 +1,1588 @@
+package java_problems.beginner;%0D%0A%0D%0Aimport java.util.Scanner;%0D%0A%0D%0A/*%0D%0A * All submissions for this problem are available.%0D%0A * %0D%0A * Now that Chef has finished baking and frosting his cupcakes, it's time to%0D%0A * package them. Chef has N cupcakes, and needs to decide how many cupcakes to%0D%0A * place in each package. Each package must contain the same number of cupcakes.%0D%0A * Chef will choose an integer A between 1 and N, inclusive, and place exactly A%0D%0A * cupcakes into each package. Chef makes as many packages as possible. Chef%0D%0A * then gets to eat the remaining cupcakes. Chef enjoys eating cupcakes very%0D%0A * much. Help Chef choose the package size A that will let him eat as many%0D%0A * cupcakes as possible.%0D%0A * %0D%0A * Input: %0D%0A * Input begins with an integer T, the number of test cases. Each test case%0D%0A * consists of a single integer N, the number of cupcakes.%0D%0A * Output%0D%0A * %0D%0A * For each test case, output the package size that will maximize the number of%0D%0A * leftover cupcakes. If multiple package sizes will result in the same number%0D%0A * of leftover cupcakes, print the largest such size.%0D%0A * %0D%0A * Constraints: %0D%0A * 1 %3C= T %3C= 1000%0D%0A * 2 %3C= N %3C= 100000000 (10%5E8)%0D%0A * %0D%0A * Sample Input: %0D%0A * 2%0D%0A * 2%0D%0A * 5%0D%0A * %0D%0A * Sample Output:%0D%0A * 2%0D%0A * 3%0D%0A */%0D%0Apublic class PackagingCupcakes %7B%0D%0A%0D%0A%09public static void main(String%5B%5D args) %7B%0D%0A%09%09%0D%0A%09%09Scanner sc = new Scanner(System.in);%0D%0A%09%09int numCases = Integer.parseInt(sc.nextLine());%0D%0A%09%09for (int i = 0; i %3C numCases; i++) %7B%0D%0A%09%09%09int numCupcakes = Integer.parseInt(sc.nextLine());%0D%0A%09%09%09System.out.println((numCupcakes / 2) + 1);%0D%0A%09%09%7D%0D%0A%09%09sc.close();%0D%0A%09%7D%0D%0A%7D

Add PackagingCupcakes