백준 8958번 (복습)

김경욱·2026년 1월 23일

백준

목록 보기
106/121

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

// Press Shift twice to open the Search Everywhere dialog and type show whitespaces,
// then press Enter. You can now see whitespace characters in your code.
public class Main {
public static void main(String[] args) throws IOException {

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

    int x = Integer.parseInt(br.readLine());

    for (int i = 0; i < x; i++) {
        String line = br.readLine();
        int score = 0;

        int succeedScore = 0;

        char[] ch = line.toCharArray();

        for (int j = 0; j < ch.length; j++) {
            if(ch[j] == 'O')
            {
                succeedScore++;
                score += succeedScore;
            }
            else{
                succeedScore=0;

            }
        }
        System.out.println(score);







    }





}

}

0개의 댓글