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 | import java.util.*; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int K = sc.nextInt(); long[] zeroCntArray = new long[K+1]; long[] oneCntArray = new long[K+1]; int i = 0; zeroCntArray[i] = 0; oneCntArray[i++] = 0; zeroCntArray[i] = 0; oneCntArray[i++] = 1; if(K >= 2){ zeroCntArray[i] = 1; oneCntArray[i++] = 1; for(; i<K+1; i++){ zeroCntArray[i] = zeroCntArray[i-1] + zeroCntArray[i-2]; oneCntArray[i] = oneCntArray[i-1] + oneCntArray[i-2]; } } System.out.println(zeroCntArray[K]+" "+oneCntArray[K]); } } |
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)
Sunday, October 18, 2015
수학귀신
창고다각형
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 53 54 55 56 57 58 59 60 61 62 | 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[][] inputArray = new int[N][2]; for(int i=0; i<N; i++){ inputArray[i][0] = sc.nextInt(); inputArray[i][1] = sc.nextInt(); } sort(inputArray); int maxHeightIndex = 0; int maxHeight = inputArray[0][1]; for(int i=0; i<N; i++){ if(inputArray[i][1] > maxHeight){ maxHeightIndex = i; maxHeight = inputArray[i][1]; } } System.out.println(maxHeightIndex+" "+maxHeight); int currentHeight = inputArray[0][1]; for(int i=0;i<maxHeightIndex;i++){ } } static void sort(int[][] inputArray){ for(int i=0; i<inputArray.length - 1; i++){ for(int j=i; j<inputArray.length - 1; j++){ if(inputArray[j][0] > inputArray[j+1][0]){ int tempLocation = inputArray[j][1]; inputArray[j][1] = inputArray[j+1][1]; inputArray[j+1][1] = tempLocation; int tempHieght = inputArray[j][0]; inputArray[j][0] = inputArray[j+1][0]; inputArray[j+1][0] = tempHieght; } } } } } |
Saturday, October 17, 2015
주차요금
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 | import java.util.*; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int M = sc.nextInt(); int[] mList = new int[M]; for(int i=0; i<M; i++){ mList[i] = sc.nextInt(); } int total = 0; for(int i=0; i<M; i++){ int subTotal = 0; if(mList[i] < 10){ subTotal = 0; }else if(mList[i] >= 10 && mList[i] <= 30){ subTotal = 500; }else{ subTotal = 500 + (((mList[i] - 31)/10) + 1) * 300; } if(subTotal > 50000){ subTotal = 50000; } total += subTotal; } System.out.println(total); } } |
잃어버린 페이지
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]); } } |
폭탄돌리기
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 53 54 55 56 57 | import java.util.*; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int K = sc.nextInt(); int N = sc.nextInt(); int[] timeArray = new int[N]; char[] answerArray = new char[N]; for(int i=0 ; i<N ; i++){ timeArray[i] = sc.nextInt(); String s = sc.next(); answerArray[i] = s.charAt(0); } int timeAnswerIdx = 0; int timer = 0; int i = K; for(;;){ if(timeAnswerIdx > N-1){ break; } int currentTime = timeArray[timeAnswerIdx]; char currentAnswer = answerArray[timeAnswerIdx]; timeAnswerIdx++; timer += currentTime; if(timer > 210){ break; } if(currentAnswer =='T'){ i++; } if(i == 9){ i = 1; } } System.out.println(i); } } |
할부
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 | 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 B = sc.nextInt(); int Quotient = B / (N-1); int min = 0; int max = 0; if(B % (N-1) == 0){ min = Quotient-1+B; max = Quotient+B; }else{ min = Quotient+B; max = Quotient+B; } System.out.println(min+" "+max); } } |
Subscribe to:
Posts (Atom)