- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColoring.java
More file actions
Latest commit
75 lines (61 loc) · 2.11 KB
/
Copy pathColoring.java
File metadata and controls
75 lines (61 loc) · 2.11 KB
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
55
56
57
58
59
60
61
62
63
64
65
importjava.io.BufferedReader;
importjava.io.BufferedWriter;
importjava.io.IOException;
importjava.io.InputStreamReader;
importjava.io.OutputStreamWriter;
importjava.util.StringTokenizer;
/**
* @백준 1117번
* @author MoonDooo
*/
publicclassColoring {
publicstaticvoidmain(String[] args) {
try{
newUnColoringAreaNum();
}catch(IOExceptione) {
e.printStackTrace();
}
}
}
classUnColoringAreaNum{
privatelongwidth;
privatelongheight;
privatelongxCoordinateToFold;
privatelongyCoordinatesNumToDivide;
privatelongx1ToColoring;
privatelongy1ToColoring;
privatelongx2ToColoring;
privatelongy2ToColoring;
privatelongresult;
publicUnColoringAreaNum() throwsIOException{
BufferedReaderbr = newBufferedReader(newInputStreamReader(System.in));
BufferedWriterbw = newBufferedWriter(newOutputStreamWriter(System.out));
InitializeInputValues(br.readLine());
longwidthColoring = 0;
if(2*xCoordinateToFold<=width) {
if(x1ToColoring>=xCoordinateToFold)widthColoring = (x2ToColoring-x1ToColoring);
elsewidthColoring = (x2ToColoring-x1ToColoring)+Math.min(xCoordinateToFold, x2ToColoring)-x1ToColoring;
}
elseif(2*xCoordinateToFold>width) {
if(width<=x1ToColoring+xCoordinateToFold)widthColoring = (x2ToColoring-x1ToColoring);
elsewidthColoring = (x2ToColoring-x1ToColoring)+Math.min(width, xCoordinateToFold+x2ToColoring)-(xCoordinateToFold+x1ToColoring);
}
widthColoring *= y2ToColoring-y1ToColoring;
result = (width*height)-(widthColoring*(yCoordinatesNumToDivide+1));
bw.write(result+"");
bw.flush();
br.close();
bw.close();
}
publicvoidInitializeInputValues(Strings) {
StringTokenizerst = newStringTokenizer(s, " ");
width = Integer.parseInt(st.nextToken());
height = Integer.parseInt(st.nextToken());
xCoordinateToFold = Integer.parseInt(st.nextToken());
yCoordinatesNumToDivide = Integer.parseInt(st.nextToken());
x1ToColoring = Integer.parseInt(st.nextToken());
y1ToColoring = Integer.parseInt(st.nextToken());
x2ToColoring = Integer.parseInt(st.nextToken());
y2ToColoring = Integer.parseInt(st.nextToken());
}
}