我这样做比较简单 public class Solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[][] array=new int[n][8]; for (int i = 0; i < n; i++) { for (int j = 0; j <8 ; j++) { array[i][j]=sc.nextInt(); } } for (int i = 0; i < n; i++) { System.out.println(isNum(array[i])?"Yes":"No"); } } public static boolean isNum(int[] array){ int[] a=new int[4]; int[] b=new int[4]; for (int i = 0; i <array.length ; i++) { if(i<4){ a[i]=array[i]; }else{ b[i-4]=array[i]; } } Arrays.sort(a); Arrays.sort(b); if((a[1]-a[0]==a[3]-a[2])&&(b[1]-b[0]==b[3]-b[2])) { return true; } return false; } }
点赞 1

相关推荐

09-29 15:34
已编辑
北京航空航天大学 C++
做个有文化的流氓:结果是好的,过程不重要,而且你的offer太多了
软开人,秋招你打算投哪些...
点赞 评论 收藏
分享
10-10 01:10
已编辑
深圳大学 测试开发
面了100年面试不知...:六月到九月,四个项目一个实习,是魔丸吗
投了多少份简历才上岸
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务