-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path_8958.java
More file actions
52 lines (46 loc) ยท 907 Bytes
/
_8958.java
File metadata and controls
52 lines (46 loc) ยท 907 Bytes
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
package backjoon;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
// https://www.acmicpc.net/problem/8958
// OXํด์ฆ
public class _8958 {
public static void main(String[] args) throws IOException {
//sol memory 12580 time 112
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int cnt = Integer.parseInt(br.readLine());
for(int i=0; i<cnt; i++){
String[] nums = br.readLine().split("");
int sum = 0; //๋์ ํฉ
int cntO = 0; //O์ ์ฐ์ ํ์
for(String s : nums){
if(s.equals("O")){
cntO++;
sum += cntO;
}else{
cntO = 0;
}
}
System.out.println(sum);
}
}
}
/*
intput
2
OOXXOXXOOO
OOXXOOXXOO
5
OOXXOXXOOO
OOXXOOXXOO
OXOXOXOXOXOXOX
OOOOOOOOOO
OOOOXOOOOXOOOOX
output
10
9
7
55
30
*/