Open hwangnk1004 opened 4 years ago
문제 http://59.23.150.58/30stair/candy/candy.php?pname=candy
import java.util.Scanner;
public class Main { public static void main(String args[]) {
Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int arr[] = new int[n]; for (int i = 0; i < n; i++) { arr[i] = scanner.nextInt(); } int count = 0; int x = 0; while (true) { count++; int avg = 0; for (int i = 0; i < arr.length; i++) { arr[i] = arr[i] / 2; } int add = arr[0]; add += arr[arr.length - 1]; if (add % 2 != 0) { add += 1; } for (int i = arr.length-1; i >=1; i--) { arr[i] += arr[i - 1]; if (arr[i] % 2 != 0) { arr[i] += 1; } avg += arr[i]; } arr[0] = add; avg += add; int k = 0; for (int i = 0; i < arr.length; i++) { if (arr[i] != avg / n) { k++; break; } } if (k == 0) { x = avg/n; break; } } System.out.println(count + " " +x); }
}
문제 http://59.23.150.58/30stair/candy/candy.php?pname=candy
답
import java.util.Scanner;
public class Main { public static void main(String args[]) {
}