Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class hw2{
- public static void main(String[] args){
- Scanner scan = new Scanner(System.in);
- int[] a = new int[16];
- //placeholder for arraycopy
- int[] b = new int[16];
- //eating counter
- int f = 0;
- for(int i=0; i<a.length; i++){
- a[i]=scan.nextInt();
- }
- for(int i=0; i<a.length; i+=2){
- for(int c=2; c<a.length-2; c+=2){
- if((a[i]==a[c])||(a[i++]==a[c++])||(Math.abs(a[c]-a[i])==Math.abs(a[c++]-a[i++]))){
- f++;
- }
- }
- //Some array magic
- System.arraycopy(a, 0, b, 2, 14);
- System.arraycopy(a, 14, b, 0, 2);
- System.arraycopy(b, 0, a, 0, 16);
- }
- if(f>0){
- System.out.println("YES");
- }else{
- System.out.println("NO");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement