| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
测试都通过了啊,为什么通不过import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int m=Integer.parseInt(sc.nextLine());
int[] a;
int total;
boolean flag=false;
while(m!=0){
flag=false;
a=new int[m];
for(int i=0;i<m;i++)
a[i]=Integer.parseInt(sc.nextLine());
total=sharing(a);
System.out.println(total+" "+a[0]);
m=Integer.parseInt(sc.nextLine());
}
}
public static boolean judgeEuqals(int[] a){
for(int i=0;i<a.length;i++)
if(a[i]!=a[0])
return false;
return true;
}
public static int sharing(int[] a){
int count=0,temp;
int[] b=new int[a.length];
while(true){
for(int i=0;i<a.length;i++)
if(a[i]%2!=0)
a[i]+=1;
for(int i=0;i<a.length;i++)
b[(i+1)%a.length]=a[i]/2;
for(int i=0;i<a.length;i++)
a[i]=a[i]/2+b[i];
if(judgeEuqals(a))
break;
count++;
}
return count;
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator