标签:http next div rgs 输入 整数 问题 朋友 oid
目录
具体代码如下:
import java.util.Scanner; public class Main { public static int N; public static int[] Child; public static int count = 0; //最终输出结果 public void getResult() { while(true) { boolean judge = true; for(int i = 1;i < N;i++) { if(Child[0] != Child[i]) { judge = false; break; } } if(judge) break; int[] half = new int[N]; for(int i = 0;i < N;i++) { if(i == N - 1) half[0] = Child[i] / 2; else half[i + 1] = Child[i] / 2; } for(int i = 0;i < N;i++) { Child[i] = Child[i] / 2 + half[i]; if(Child[i] % 2 == 1) { count++; Child[i]++; } } } System.out.println(count); } public static void main(String[] args) { Main test = new Main(); Scanner in = new Scanner(System.in); N = in.nextInt(); Child = new int[N]; for(int i = 0;i < N;i++) Child[i] = in.nextInt(); test.getResult(); } }
标签:http next div rgs 输入 整数 问题 朋友 oid
原文地址:http://www.cnblogs.com/liuzhen1995/p/6800563.html