File tree 4 files changed +64
-0
lines changed
4 files changed +64
-0
lines changed Original file line number Diff line number Diff line change 24
24
| 02 | | [ Baekjoon-14891 ํฑ๋๋ฐํด] ( ./src/Simulation/P14891 ) | |
25
25
| 03 | | [ Baekjoon-15662 ํฑ๋๋ฐํด (2)] ( ./src/Simulation/P15662 ) | |
26
26
| 04 | | [ Baekjoon-12100 2048 (Easy)] ( ./src/Simulation/P12100 ) | ์ผ์ฑ SW ์ญ๋ ํ
์คํธ ๊ธฐ์ถ |
27
+ | 05 | | [ Baekjoon-1244 ์ค์์น ์ผ๊ณ ๋๊ธฐ] ( ./src/Simulation/P1244 ) | |
27
28
28
29
## String
29
30
Original file line number Diff line number Diff line change
1
+ package Simulation .P1244 ;
2
+
3
+ import java .io .*;
4
+ import java .util .*;
5
+
6
+ public class Main {
7
+
8
+ static int N , S ;
9
+ static int [] switches ;
10
+
11
+ public static void main (String [] args ) throws Exception {
12
+ System .setIn (new FileInputStream ("src/Simulation/P1244/input.txt" ));
13
+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
14
+
15
+ N = Integer .parseInt (br .readLine ());
16
+ switches = new int [N +1 ];
17
+
18
+ StringTokenizer st = new StringTokenizer (br .readLine ());
19
+ for (int i = 1 ; i <= N ; i ++) switches [i ] = Integer .parseInt (st .nextToken ());
20
+
21
+ S = Integer .parseInt (br .readLine ());
22
+ while (S -- > 0 ) {
23
+ st = new StringTokenizer (br .readLine ());
24
+ int gender = Integer .parseInt (st .nextToken ());
25
+ int num = Integer .parseInt (st .nextToken ());
26
+
27
+ if (gender == 1 ) {
28
+ for (int i = num ; i <= N ; i += num ) changeSwitch (i );
29
+ } else if (gender == 2 ) {
30
+ changeSwitch (num );
31
+ int i = 1 ;
32
+ while (0 < num -i && num +i <= N ) {
33
+ if (switches [num -i ] == switches [num +i ]) {
34
+ changeSwitch (num -i );
35
+ changeSwitch (num +i );
36
+ i ++;
37
+ } else break ;
38
+ }
39
+ }
40
+ }
41
+
42
+ for (int i = 1 ; i <= N ; i ++) {
43
+ System .out .print (switches [i ] + " " );
44
+ if (i % 20 == 0 ) System .out .println ();
45
+ }
46
+ }
47
+
48
+ static void changeSwitch (int i ) {
49
+ switches [i ] = switches [i ] == 0 ? 1 : 0 ;
50
+ }
51
+ }
Original file line number Diff line number Diff line change
1
+ ## [ baekjoon-1244] ์ค์์น ์ผ๊ณ ๋๊ธฐ
2
+
3
+ ![ image] ( https://user-images.githubusercontent.com/22045163/106439518-1e015d80-64bb-11eb-9f89-d91f1f8ed942.png )
4
+ ![ image] ( https://user-images.githubusercontent.com/22045163/106439564-2e193d00-64bb-11eb-8edf-a7cb1803fd51.png )
Original file line number Diff line number Diff line change
1
+ 8
2
+ 0 1 0 1 0 0 0 1
3
+ 2
4
+ 1 3
5
+ 2 3
6
+
7
+ //output
8
+ 1 0 0 0 1 1 0 1
You canโt perform that action at this time.
0 commit comments