File tree Expand file tree Collapse file tree 2 files changed +62
-0
lines changed
Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 1+ import java .io .*;
2+
3+ class Main {
4+ public static void main (String [] args ) throws Exception {
5+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
6+ int testCase = Integer .parseInt (br .readLine ());
7+ StringBuilder st = new StringBuilder ();
8+ while (testCase -- > 0 ){
9+ st .append (solve (br .readLine ()));
10+ st .append ("\n " );
11+ }
12+ System .out .println (st );
13+ }
14+
15+ static int solve (String input ){
16+ char [] cArr = input .toCharArray ();
17+
18+ int chain = 1 ;
19+ int sum = 0 ;
20+ for (char c : cArr ){
21+ if (c == 'O' ){
22+ sum += chain ;
23+ chain ++;
24+ } else {
25+ chain = 1 ;
26+ }
27+ }
28+ return sum ;
29+ }
30+ }
Original file line number Diff line number Diff line change 1+ # [ Bronze II] OX퀴즈 - 8958
2+
3+ [ 문제 링크] ( https://www.acmicpc.net/problem/8958 )
4+
5+ ### 성능 요약
6+
7+ 메모리: 11664 KB, 시간: 68 ms
8+
9+ ### 분류
10+
11+ 구현, 문자열
12+
13+ ### 제출 일자
14+
15+ 2025년 8월 2일 14:27:39
16+
17+ ### 문제 설명
18+
19+ <p >"OOXXOXXOOO"와 같은 OX퀴즈의 결과가 있다. O는 문제를 맞은 것이고, X는 문제를 틀린 것이다. 문제를 맞은 경우 그 문제의 점수는 그 문제까지 연속된 O의 개수가 된다. 예를 들어, 10번 문제의 점수는 3이 된다.</p >
20+
21+ <p >"OOXXOXXOOO"의 점수는 1+2+0+0+1+0+0+1+2+3 = 10점이다.</p >
22+
23+ <p >OX퀴즈의 결과가 주어졌을 때, 점수를 구하는 프로그램을 작성하시오.</p >
24+
25+ ### 입력
26+
27+ <p >첫째 줄에 테스트 케이스의 개수가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있고, 길이가 0보다 크고 80보다 작은 문자열이 주어진다. 문자열은 O와 X만으로 이루어져 있다.</p >
28+
29+ ### 출력
30+
31+ <p >각 테스트 케이스마다 점수를 출력한다.</p >
32+
You can’t perform that action at this time.
0 commit comments