Skip to content

Commit 4280f48

Browse files
authored
[20251216] BOJ / G3 / 프랙탈 평면 / 이종환
1 parent 00977d6 commit 4280f48

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
```java
2+
import java.util.*;
3+
import java.io.*;
4+
5+
public class Main {
6+
/*
7+
* R도, C도 아래의 조건이 성립해야함
8+
* S초일때, 대상의 좌표를 N^(1~s)로 나누었을때, 나머지가 ( (N-K)/2~ (N+k)/2 -1 ) * N^(0~s-1)에 포함되면 됨. 이걸 하나라도 만족하면 그 칸은 검정.
9+
* */
10+
11+
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
12+
static StringBuilder sb = new StringBuilder();
13+
14+
static int s,N,K,R1,R2,C1,C2;
15+
16+
public static void main(String[] args) throws IOException {
17+
init();
18+
process();
19+
print();
20+
21+
}
22+
23+
private static void init() throws IOException {
24+
25+
StringTokenizer st = new StringTokenizer(br.readLine());
26+
s = Integer.parseInt(st.nextToken());
27+
N = Integer.parseInt(st.nextToken());
28+
K = Integer.parseInt(st.nextToken());
29+
R1 = Integer.parseInt(st.nextToken());
30+
R2 = Integer.parseInt(st.nextToken());
31+
C1 = Integer.parseInt(st.nextToken());
32+
C2 = Integer.parseInt(st.nextToken());
33+
34+
35+
36+
}
37+
38+
39+
private static void process() {
40+
for (int i = R1; i <= R2; i++) {
41+
for (int j = C1; j <= C2; j++) {
42+
43+
boolean isBlack = check(i,j);
44+
sb.append(isBlack?1:0);
45+
}
46+
sb.append("\n");
47+
}
48+
49+
}
50+
51+
private static boolean check(int y,int x) {
52+
53+
for (int time = 1; time <= s; time++) {
54+
int divisor = (int) Math.pow(N,time);
55+
int yRemainder = y%divisor;
56+
int xRemainder = x%divisor;
57+
58+
int st = (N-K)/2 * (divisor/N);
59+
int end = ((N+K)/2)* (divisor/N)-1;
60+
61+
if(yRemainder >= st && yRemainder <= end
62+
&& xRemainder >= st && xRemainder <= end) return true;
63+
}
64+
return false;
65+
}
66+
67+
68+
private static void print() {
69+
System.out.print(sb);
70+
}
71+
}
72+
```

0 commit comments

Comments
 (0)