Advertisement
jenrus

Задача №3176. Ферзи (всё, кроме 1, 4, 5)

Oct 19th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class hw2{
  4.     public static void main(String[] args){
  5.         Scanner scan = new Scanner(System.in);
  6.         int[] a = new int[16];
  7.         //placeholder for arraycopy
  8.         int[] b = new int[16];
  9.         //eating counter
  10.         int f = 0;
  11.         for(int i=0; i<a.length; i++){
  12.             a[i]=scan.nextInt();
  13.         }
  14.         for(int i=0; i<a.length; i+=2){
  15.             for(int c=2; c<a.length-2; c+=2){
  16.                 if((a[i]==a[c])||(a[i++]==a[c++])||(Math.abs(a[c]-a[i])==Math.abs(a[c++]-a[i++]))){
  17.                     f++;
  18.                 }
  19.             }
  20.             //Some array magic
  21.             System.arraycopy(a, 0, b, 2, 14);
  22.             System.arraycopy(a, 14, b, 0, 2);
  23.             System.arraycopy(b, 0, a, 0, 16);
  24.         }
  25.         if(f>0){
  26.             System.out.println("YES");
  27.         }else{
  28.             System.out.println("NO");
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement