목록coding study (269)
happy coding
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { // 9개의 서로 다른 자연수를 개행으로 입력받음 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int[] array = new int[9]; int i; for (i = 0; i < array.length; i++) { array[i] = Integer.parseInt(br.readLine()); } // 최댓값을 찾고 그 수가 몇 번째 수인..
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { //숫자 세 개 띄어쓰기로 입력 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine(), " "); int[] arr = new int[3]; for (int i=0 ; i
import java.io.*; public class Main { public static void main(String[] args) throws IOException { //m과 n 값 개행으로 입력받음 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int m = Integer.parseInt(br.readLine()); //시작 int n = Integer.parseInt(br.readLine()); //끝 boolean hasPerfectSquare = false; int sum = 0; int min = Integer.MAX_VALUE; //초기값이 최솟값보다 항상 크다고 보장하도록 for (int i = m..
import java.io.*; public class Main { public static void main(String[] args) throws IOException { //n 입력받기 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); long n = Long.parseLong(br.readLine()); int count = 0; while (n>3) { count++; //무조건 더하고 시작 n = n/2 + (n%2 == 1? 1:0); //2배로 나누고, 나눈 값이 1이라면 1 더하기 } System.out.println(count + n); } } 메서드 생성해서 풀다가, 점점 길어지고 복잡해지는 코드를 보면..
import java.io.*; public class Main { public static void main(String[] args) throws IOException { // 도착지인 N값 입력받음 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); long N = Long.parseLong(br.readLine()); // 벌집의 중앙에서 시작하여 최소 개수의 방을 지나서 도착하는 방법 계산 long room = 1; // 시작 방 번호 long cnt = 1; // 지나가는 방의 개수 long step = 6; // 방 번호 증가량 while (room < N) { room += step; step += 6; cnt..
for (int j = 2; j
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { //첫째 줄에 수의 개수 n을 입력받음 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[] array = new int[n]; //둘째 줄부터 N개의 줄에는 수가 주어짐 for (int i=0 ; i
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { //카드의 개수 n과 숫자 m을 입력받음 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine(), " "); int n = Integer.parseInt(st.nextToken()); int m = Integer.parseInt(st.nextToken()); int[] num = new int[n]; //카드에 쓰여 있는 수..