1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | import java.util.*; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int P = sc.nextInt(); int pageArrayRow = N/4; int[][] pageArray = new int[pageArrayRow][4]; int number = 1; for(int i=0; i<pageArrayRow; i++){ pageArray[i][0] = number++; pageArray[i][1] = number++; } for(int i=N/4-1; i>=0; i--){ pageArray[i][2] = number++; pageArray[i][3] = number++; } int index = 0; if(P > N/2){ if(P%2 == 0){ index = Math.abs((P-N/2)/2 - (N/4)); }else{ index = Math.abs((P-N/2)/2 - (N/4-1)); } }else{ index = (P-1)/2; } int[] answer = new int[3]; int answerIndex = 0; for(int i=0; i<4; i++){ if(pageArray[index][i] != P){ answer[answerIndex++]= pageArray[index][i]; } } System.out.println(answer[0]+" "+answer[1]+" "+answer[2]); } } |
Labels
Programming
(16)
Algorithm
(15)
Java
(15)
ASP .NET
(4)
Enterprise Architecture
(4)
PHP and MySQL
(4)
Software Engineering
(2)
C#
(1)
Data Mining
(1)
Deep Learning
(1)
Java Script
(1)
Python
(1)
Saturday, October 17, 2015
잃어버린 페이지
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment