Skip to content

Commit bf85095

Browse files
committed
[Math] baekjoon-13458
1 parent 0e8feab commit bf85095

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

β€ŽREADME.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@
204204
| 01 | | [Baekjoon-1717 μ§‘ν•©μ˜ ν‘œν˜„](./src/Graph/P1717) | [Disjoint Set](./notes/Graph/DisjointSet.md) |
205205
| 02 | | [Baekjoon-2252 쀄 μ„Έμš°κΈ°](./src/Graph/P2252) | [μœ„μƒμ •λ ¬](./notes/Graph/TopologicalSort.md) |
206206

207+
## Math
208+
209+
| # | β˜† | Problem | Note |
210+
| :-: | :-: | :--------------------------------------------- | :----- |
211+
| 01 | | [Baekjoon-13458 μ‹œν—˜ 감독](./src/Math/P13458) | |
212+
207213
## Number Theory
208214

209215
### GCD

β€Žsrc/Math/P13458/Main.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package Math.P13458;
2+
3+
import java.io.*;
4+
import java.util.StringTokenizer;
5+
6+
public class Main {
7+
8+
static int N, B, C;
9+
static int[] A;
10+
11+
public static void main(String[] args) throws Exception {
12+
System.setIn(new FileInputStream("src/Math/P13458/input.txt"));
13+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
14+
15+
N = Integer.parseInt(br.readLine());
16+
A = new int[N];
17+
18+
StringTokenizer st = new StringTokenizer(br.readLine());
19+
for (int i = 0; i < N; i++) A[i] = Integer.parseInt(st.nextToken());
20+
21+
st = new StringTokenizer(br.readLine());
22+
B = Integer.parseInt(st.nextToken());
23+
C = Integer.parseInt(st.nextToken());
24+
25+
long sum = N;
26+
for (int i = 0; i < N; i++) sum += A[i] - B > 0 ? Math.ceil((double)(A[i] - B) / C) : 0;
27+
System.out.println(sum);
28+
}
29+
}

β€Žsrc/Math/P13458/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## [baekjoon-13458] μ‹œν—˜ 감독
2+
3+
![image](https://user-images.githubusercontent.com/22045163/107942623-d73d5880-6fce-11eb-9800-bde8a37b040f.png)
4+
5+
### μ£Όμ˜ν•΄μ•Ό ν•  점
6+
7+
- 문제의 λ²”μœ„λ₯Ό κ³ λ €ν–ˆμ„ λ•Œ 총 감독관 수λ₯Ό 담을 λ³€μˆ˜μ˜ μžλ£Œν˜•μ€ `long`이어야 ν•œλ‹€.
8+
- `A[i] - B`의 값이 음수일 경우 λ‚˜λˆ—μ…ˆμ„ ν–ˆμ„ λ•Œ μŒμˆ˜κ°’μ΄ λ‚˜μ˜¬ 수 μžˆμœΌλ―€λ‘œ ν•΄λ‹Ή 값이 0을 λ„˜μ„ λ•Œλ§Œ κ³„μ‚°ν•˜λ„λ‘ 쑰건을 μΆ”κ°€ν•΄μ£Όμ–΄μ•Ό ν•œλ‹€.
9+
10+
![image](https://user-images.githubusercontent.com/22045163/107942648-e3291a80-6fce-11eb-91e5-5a4deb939c0d.png)

β€Žsrc/Math/P13458/input.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1
2+
1
3+
50 2

0 commit comments

Comments
Β (0)