Home B8958. OX퀴즈
Post
Cancel

B8958. OX퀴즈

문제

image

제출 코드

image

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
package baekjoon;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class baek8958_OXquiz {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int T = Integer.parseInt(br.readLine());
		for(int t = 0; t < T; t++) {

			String line = br.readLine();
			int cnt = 0;
			int total = 0;

			for(int i = 0; i < line.length(); i++) {
				if (line.charAt(i) == 'O' ) {
					cnt++;
					total += cnt;
				}else {
					cnt = 0;
				}
			}
			System.out.println(total);
		}
	}

}
This post is licensed under CC BY 4.0 by the author.