File tree Expand file tree Collapse file tree 4 files changed +41
-0
lines changed Expand file tree Collapse file tree 4 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 14
14
| # | ☆ | Problem | Note |
15
15
| :-: | :-: | :------------------------------------------------------- | :--- |
16
16
| 01 | | [ Codility-Lesson1 BinaryGap] ( ./src/Iterations/BinaryGap ) | |
17
+ | 02 | | [ SWEA-1289 원재의 메모리 복구하기] ( ./src/Iterations/swea1289 ) | |
17
18
18
19
## Simulation
19
20
Original file line number Diff line number Diff line change
1
+ ## [ SW Expert Academy - 1289] 원재의 메모리 복구하기
2
+
3
+ ![ image] ( https://user-images.githubusercontent.com/22045163/106429941-7ed66900-64ae-11eb-89ca-e161485f6530.png )
4
+
5
+ ![ image] ( https://user-images.githubusercontent.com/22045163/106429801-48005300-64ae-11eb-82d9-1076ad145137.png )
Original file line number Diff line number Diff line change
1
+ package Iterations .swea1289 ;
2
+
3
+ import java .io .*;
4
+
5
+ public class Solution {
6
+
7
+ static int T ;
8
+ static String input ;
9
+ static StringBuilder sb = new StringBuilder ();
10
+
11
+ public static void main (String [] args ) throws Exception {
12
+ System .setIn (new FileInputStream ("src/Iterations/swea1289/input.txt" ));
13
+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
14
+
15
+ T = Integer .parseInt (br .readLine ());
16
+
17
+ for (int t = 1 ; t <= T ; t ++) {
18
+ sb .append ("#" ).append (t ).append (" " );
19
+ input = br .readLine ();
20
+ int cnt = 0 ;
21
+ char cursor = '0' ;
22
+ for (int i = 0 ; i < input .length (); i ++) {
23
+ if (input .charAt (i ) == cursor ) continue ;
24
+ cursor = (cursor == '0' ) ? '1' : '0' ;
25
+ cnt ++;
26
+ }
27
+ sb .append (cnt ).append ("\n " );
28
+ }
29
+
30
+ System .out .println (sb .toString ());
31
+ }
32
+ }
Original file line number Diff line number Diff line change
1
+ 2
2
+ 0011
3
+ 100
You can’t perform that action at this time.
0 commit comments