백준 8958 (파이썬)

김덕현·2021년 5월 30일
1

BAEKJOON

목록 보기
36/62

1.문제

https://www.acmicpc.net/problem/8958

2.코드

import sys
n=int(input())
for i in range(n):
    a=list(sys.stdin.readline().rstrip())
    scr=0
    bonus=0
    for j in range(len(a)):
        if j == 0 :
            if a[0] == 'O':scr+=1
        else :
            if a[j] == 'O':
                if a[j-1] == 'O' :
                    bonus+=1
                    scr+=bonus+1
                else : scr+=1
            else : bonus=0
    print(scr)

3.코드해설

profile
BAEKJOON STUDYING

0개의 댓글