일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Oracle 초기 사용자
- oracle
- 오라클 캐릭터셋 조회
- ora-01722
- Oracle 사용자명 입력
- 서평단
- 무료 오라클 데이터베이스
- Oracle 테이블 띄어쓰기
- 오라클 캐릭터셋 확인
- Orace 18c
- ORA-00922
- oracle 18c
- 오라클 캐릭터셋 변경
- Oracle Express Edition
- Oracle 윈도우 설치
- Oracle 18c HR schema
- Oracle 테이블 대소문자
- Oracle 18c 설치
- 윈도우 Oracle
- 비전공자를 위한 데이터베이스 입문
- Oracle 사용자명
- Oracle 18c HR
- 무료 오라클 설치
- ORA-12899
Archives
- Today
- Total
The Nirsa Way
[백준] 알고리즘 단계별로 풀어보기 - 1 (자바) 본문
반응형
백준 알고리즘 단계별로 풀어보기 - 1 후기(자바)
하루 1~2시간은 백준 문제 풀려고 합니다!
맨앞부분은 옛날에 파이썬으로 풀었던게 있어서 스킵 했습니다. 이런 문제들을 풀어본 경험이 없어서 그런지, 극 초반부인데도 문제를 읽고 이해하는 과정이 너무 어려웠네요.
10926번: ??!
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String id = sc.next();
System.out.printf("%s??!",id);
}
}
18108번: 1998년생인 내가 태국에서는 2541년생?!
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
short year = sc.nextShort();
System.out.printf("%d",(year-543));
}
}
14681번: 사분면 고르기
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num1 = sc.nextInt();
int num2 = sc.nextInt();
if(num1>0 && num2>0) {
System.out.println("1");
} else if(num1<0 && num2>0) {
System.out.println("2");
} else if(num1<0 && num2<0) {
System.out.println("3");
} else if(num1>0 && num2<0) {
System.out.println("4");
}
}
}
2884번: 알람 시계
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
short H = sc.nextShort();
short M = sc.nextShort();
if((0<=H || H<=23) && (0<=M || M<=59)) {
int alarmM = M-45;
if(alarmM >= 0) {
System.out.printf("%d %d", H, alarmM);
} else if(alarmM < 0 && H > 0) {
System.out.printf("%d %d", H-1, (60-(-alarmM)));
} else if(alarmM < 0 && H == 0) {
System.out.printf("%d %d", 23, (60-(-alarmM)));
}
}
}
}
2525번: 오븐 시계
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
short A = sc.nextShort();
int B = sc.nextShort() + sc.nextShort();
while ( B > 59) {
A++;
B -= 60;
if(A>23) {
A -= 24;
}
}
System.out.printf("%d %d", A, B);
}
}
2480번: 주사위 세개 (틀렸습니다.)
어느 부분에서 틀린건지 모르겠네요.... 다른 문제 풀다가 다시 돌아와서 풀어봐야겠습니다
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
short A = sc.nextShort();
short B = sc.nextShort();
short C = sc.nextShort();
if(A==B && B==C) {
System.out.printf("%d", (10000+(A*1000)));
} else if(A==B || B==C || A==C) {
if(A==B || B==C) {
System.out.printf("%d", (1000+(B*100)));
} else if(A==C) {
System.out.printf("%d", (1000+(A*100)));
}
} else if(A!=B && B!=C) {
if(A>B || A>C) {
System.out.printf("%d", (A*100));
} else if(B>C || B>A) {
System.out.printf("%d", (B*100));
} else if(C>A || C>B) {
System.out.printf("%d", (C*100));
}
}
}
}
2739번: 구구단
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
short dan = sc.nextShort();
for(int i=1; i<10; i++) {
System.out.printf("%d * %d = %d \n", dan, i, dan*i);
}
}
}
10950번: A+B - 3
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
short T = sc.nextShort();
for(int i=0; i<T; i++) {
short num1 = sc.nextShort();
short num2 = sc.nextShort();
System.out.printf("%d \n", num1+num2);
}
}
}
8393번: 합
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int sum = 0;
for(int i=1; i<=n; i++) {
sum = sum + i ;
}
System.out.printf("%d \n", sum);
}
}
15552번: 빠른 A + B
BufferedReader , BufferedWriter 사용법을 보며 풀기는 했으나, 어떤식으로 동작하는지 잘 이해가 안가네요. 좀 더 사용법에 대해 알아봐야겠습니다.
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
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));
long T = Integer.parseInt(br.readLine());
StringTokenizer st;
for(int i=1; i<=T; i++) {
st = new StringTokenizer(br.readLine()," ");
bw.write(Integer.parseInt(st.nextToken()) + Integer.parseInt(st.nextToken())+"\n");
}
br.close();
bw.flush();
bw.close();
}
}
반응형
'코딩 테스트 > 백준' 카테고리의 다른 글
[백준] 2577번: 숫자의 개수 (JAVA, 자바) (0) | 2022.03.15 |
---|---|
[백준] 2562번: 최댓값 (JAVA, 자바) (0) | 2022.03.15 |
[백준] 10818번: 최소, 최대 (JAVA, 자바) (0) | 2022.03.15 |
[백준] 알고리즘 단계별로 풀어보기 - 3 (자바) (0) | 2022.03.09 |
[백준] 알고리즘 단계별로 풀어보기 - 2 (자바) (0) | 2022.03.07 |