-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path피로도.java
33 lines (29 loc) · 1012 Bytes
/
피로도.java
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
package week4_0408;
import java.io.*;
import java.util.*;
public class 피로도 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int a = Integer.parseInt(st.nextToken()); // 쌓이는 피로도
int b = Integer.parseInt(st.nextToken()); // 일
int c = Integer.parseInt(st.nextToken()); // 회복 피로도
int m = Integer.parseInt(st.nextToken()); // 번아웃
int tired = 0, work = 0;
int DAY = 24;
for (int i=0; i<DAY; i++) {
if (tired + a <= m) {
tired += a;
work += b;
} else {
if (tired - c >= 0) tired -= c;
else {
while (tired > 0) {
tired--;
}
}
}
}
System.out.println(work);
}
}