반응형
1712번
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
st = new StringTokenizer(br.readLine()," ");
int A = Integer.parseInt(st.nextToken());
int B = Integer.parseInt(st.nextToken());
int C = Integer.parseInt(st.nextToken());
if(C <= B)
System.out.println("-1");
else
System.out.println((A / (C - B)) + 1);
}
}
|
cs |
2292번
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
|
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
// 최소 개수
int cnt = 1;
while(true) {
int num = cnt - 1;
// 범위의 끝 값(1, 7, 19, 37, 61......)
int temp = 6 * (num * (num + 1) / 2) + 1;
if(N <= temp) {
System.out.println(cnt);
break;
}
cnt++;
}
}
}
|
cs |
1193번
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
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
int line = 0;
int num = 0;
// 몇 번째 대각선인지 찾기
for(int i = 0; i <= N; i++) {
num += i;
if(num >= N) {
line = i;
break;
}
}
if(line % 2 == 0)
System.out.println(line - (num - N) + "/" + (1 + num - N));
else
System.out.println((1 + num - N) + "/" + (line - (num - N)));
}
}
|
cs |
2869번
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
|
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
st = new StringTokenizer(br.readLine()," ");
// 낮에 올라가는 높이
int A = Integer.parseInt(st.nextToken());
// 밤에 떨어지는 높이
int B = Integer.parseInt(st.nextToken());
// 나무 높이
int V = Integer.parseInt(st.nextToken());
int day = (V - B) / (A - B);
if((V - B) % (A - B) != 0)
day++;
System.out.println(day);
}
}
|
cs |
10250번
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
|
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
StringTokenizer st;
int num = Integer.parseInt(br.readLine());
for(int i = 0; i < num; i++) {
st = new StringTokenizer(br.readLine()," ");
int H = Integer.parseInt(st.nextToken());
int W = Integer.parseInt(st.nextToken());
int N = Integer.parseInt(st.nextToken());
if(N % H == 0)
sb.append((H * 100) + (N / H)).append("\n");
else
sb.append(((N % H) * 100) + ((N / H) + 1)).append("\n");
}
System.out.println(sb);
}
}
|
cs |
2775번
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
|
import java.io.*;
import java.util.*;
public class Main {
public static int[][] arr = new int[15][15];
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
setArray();
int T = Integer.parseInt(br.readLine());
for(int i = 0; i < T; i++) {
int k = Integer.parseInt(br.readLine());
int n = Integer.parseInt(br.readLine());
sb.append(arr[k][n]).append("\n");
}
System.out.println(sb);
}
public static void setArray() {
for (int i = 0; i < 15; i++) {
arr[i][1] = 1; // i층 1호
arr[0][i] = i; // 0층 i호
}
for (int i = 1; i < 15; i++) {
for (int j = 2; j < 15; j++) {
arr[i][j] = arr[i][j - 1] + arr[i - 1][j];
}
}
}
}
|
cs |
2839번
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.*;
import java.io.*;
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));
int N = Integer.parseInt(br.readLine());
int cnt = 0;
while(true) {
if(N % 5 == 0) {
cnt += N / 5;
System.out.println(cnt);
break;
}
else {
N -= 3;
cnt++;
}
if(N < 0) {
System.out.println("-1");
break;
}
}
}
}
|
cs |
10757번
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
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;
st = new StringTokenizer(br.readLine()," ");
BigInteger A = new BigInteger(st.nextToken());
BigInteger B = new BigInteger(st.nextToken());
System.out.println(A.add(B));
}
}
|
cs |
1011번
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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
StringTokenizer st;
int T = Integer.parseInt(br.readLine());
for(int i = 0; i < T; i++) {
st = new StringTokenizer(br.readLine()," ");
int x = Integer.parseInt(st.nextToken());
int y = Integer.parseInt(st.nextToken());
int distance = y - x;
int temp = (int)Math.sqrt(distance);
int cnt = 0;
if(temp == Math.sqrt(distance)) {
cnt = 2 * temp - 1;
sb.append(cnt).append("\n");
}
else if(distance <= temp * temp + temp) {
cnt = 2 * temp;
sb.append(cnt).append("\n");
}
else {
cnt = 2 * temp + 1;
sb.append(cnt).append("\n");
}
}
System.out.println(sb);
}
}
|
cs |
반응형
'백준' 카테고리의 다른 글
백준 10단계 (재귀) (0) | 2021.04.24 |
---|---|
백준 9단계 (기본 수학2) (0) | 2021.04.21 |
백준 7단계 (문자열) (0) | 2021.04.15 |
백준 6단계 (함수) (0) | 2021.04.11 |
백준 5단계 (1차원 배열) (0) | 2021.04.08 |