a005.
Eva 的回家作業
--
POJ
| From: [140.129.108.162] |
發表日期
:
2013-04-16 11:19
import java.util.*;
class A005{
public static void main(String[] args){
Scanner s = new Scanner(System.in);
while(s.hasNext()){
int [] arr =new int [5];
int [] d =new int[3];
int [] r =new int[3];
for(int i=0;i<arr.length-1;i++){
arr[i]=s.nextInt();
if(arr[i]<0||arr[i]>20)
return;
}
for(int j=0;j<3;j++){
try{
d[j]=arr[j+1]-arr[j];
r[j]=arr[j+1]/arr[j];
}catch(ArrayIndexOutOfBoundsException e){}
}
if(d[0]==d[1]&&d[1]==d[2]){
arr[4]=d[0]+arr[3];
for(int i=0;i<=arr.length-2;i++){
System.out.print(arr[i]);
}
System.out.println(arr[4]);
}else if(r[0]==r[1]&&r[1]==r[2]){
arr[4]=r[0]*arr[3];
for(int i=0;i<=arr.length-2;i++){
System.out.print(arr[i]);
}
System.out.println(arr[4]);
}else{
return;
}
}
}
}