Algorithm

    백준 15552 (빠른 A+B)

    1234567891011121314151617181920212223242526272829import java.io.*;import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { // 입출력 예외처리 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // 버퍼를 이용한 입력 BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); // 버퍼를 이용한 출력 StringTokenizer st; // 하나의 문..

    백준 2480 (주사위 세개)

    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 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int a = scan.nextInt(); int b = scan.nextInt(); int c = scan.nextInt(); if(a==b && b==c && c==a) { // 같은 눈이 3개일 경우 System.out.println(10000 + a * 1000); } else if(a==b || b==c)..

    백준 2525 (오븐 시계)

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int hour = scan.nextInt(); // 시간 int min = scan.nextInt(); // 분 int oven =scan.nextInt(); // 오븐이 걸리는 시간(분) if(min+oven>=60) { // 60분 이상일경우 hour += (min+oven) / 60; // 나눈 몫을 hour에 +한다 min = (min+oven) % 60; // ..

    백준 2884 (알람 시계)

    1234567891011121314151617181920212223242526import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int a = scan.nextInt(); // hour를 입력 int b = scan.nextInt(); // minute을 입력 scan.close(); if(b

    백준 1152 (단어의 개수)

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import java.util.Scanner; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String input = scan.nextLine(); scan.close(); StringTokenizer st = new StringTokenizer(input," "); // input(문자열)값을 " "(공백)기준으로 각각 나누어 토큰화 System.out.println(st.countTokens()); // 나누어진 토큰 갯수를 출력 } } C..

    백준 2754 (학점 계산)

    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 import java.util.Scanner; public class baekjoon_2754 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String input = scan.nextLine(); float a = 0f; if(input.charAt(0)=='A') { a += 4.0; if(input.charAt(1)=='+') { ..

    백준 2744 (대소문자 바꾸기)

    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 import java.util.Scanner; public class baekjoon_2744 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String input = scan.nextLine(); // 문자열(input)을 char형식의 배열 a에 저장 char[] a = input.toCharArray(); for(int i=0; i='A' && a[i]='a' && a[i]

    백준 2738 (행렬 덧셈)

    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 import java.util.Scanner; public class baekjoon_2738 { // 행렬 덧셈 public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int M = scan.nextInt(); // N * M 크기의 행렬 생성 int sum[][] = new int[N][M]; // N * M의 행렬의 각각 원소 값을 두 번씩 입력 받아 더한다. for(int i=0; i