Skip to content

Commit 84534de

Browse files
committed
[Iterations] swea-7964
1 parent 3eddb76 commit 84534de

File tree

5 files changed

+56
-0
lines changed

5 files changed

+56
-0
lines changed

โ€ŽREADME.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
| 01 | | [Codility-Lesson1 BinaryGap](./src/Iterations/BinaryGap) | |
1717
| 02 | | [SWEA-1289 ์›์žฌ์˜ ๋ฉ”๋ชจ๋ฆฌ ๋ณต๊ตฌํ•˜๊ธฐ](./src/Iterations/swea1289) | |
1818
| 03 | | [SWEA-3499 ํผํŽ™ํŠธ ์…”ํ”Œ](./src/Iterations/swea3499) | |
19+
| 04 | | [SWEA-7964 ๋ถ€๋จน์™•๊ตญ์˜ ์ฐจ์› ๊ด€๋ฌธ](./src/Iterations/swea7964) | |
1920

2021
## Recursion
2122

โ€Žsrc/Iterations/swea7964/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## [SW Expert Academy - 7964] ๋ถ€๋จน์™•๊ตญ์˜ ์ฐจ์› ๊ด€๋ฌธ
2+
3+
![image](https://user-images.githubusercontent.com/22045163/109156080-c8675a80-77b3-11eb-8cd3-b342cc682bb5.png)
4+
![image](https://user-images.githubusercontent.com/22045163/109156125-d1f0c280-77b3-11eb-8ab6-e0078da11284.png)
5+
6+
![image](https://user-images.githubusercontent.com/22045163/109156160-dcab5780-77b3-11eb-9ca6-c9d83bad3ca1.png)
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package Iterations.swea7964;
2+
3+
import java.io.BufferedReader;
4+
import java.io.FileInputStream;
5+
import java.io.InputStreamReader;
6+
import java.util.StringTokenizer;
7+
8+
public class Solution {
9+
10+
static int T, N, D, C;
11+
12+
public static void main(String[] args) throws Exception {
13+
System.setIn(new FileInputStream("src/Iterations/swea7964/input.txt"));
14+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
15+
StringBuilder sb = new StringBuilder();
16+
17+
T = Integer.parseInt(br.readLine());
18+
for (int t = 1; t <= T; t++) {
19+
StringTokenizer st = new StringTokenizer(br.readLine());
20+
N = Integer.parseInt(st.nextToken());
21+
D = Integer.parseInt(st.nextToken());
22+
23+
int cnt = 0, dist = 0;
24+
st = new StringTokenizer(br.readLine());
25+
for (int i = 1; i <= N; i++) {
26+
C = Integer.parseInt(st.nextToken());
27+
if (C == 1) {
28+
dist = 0;
29+
} else {
30+
dist ++;
31+
if (dist == D) { cnt ++; dist = 0; }
32+
}
33+
}
34+
35+
sb.append("#").append(t).append(" ").append(cnt).append("\n");
36+
}
37+
System.out.println(sb.toString());
38+
}
39+
}

โ€Žsrc/Iterations/swea7964/input.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
3
2+
6 2
3+
1 0 0 0 0 1
4+
10 2
5+
0 0 1 0 1 0 0 0 0 1
6+
10 1
7+
0 0 0 0 0 0 0 0 0 0
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#1 2
2+
#2 3
3+
#3 10

0 commit comments

Comments
ย (0)