슈콩

[SWEA] 방울 마술 본문

Algorithms/SWEA

[SWEA] 방울 마술

shukong 2025. 11. 23. 23:27

 

 

[문제]

https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AY9QTGqqcckDFAVF

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

 

 

[소스 코드]

import java.io.*;
import java.util.*;
public class Solution {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		int T = Integer.parseInt(br.readLine());
		for(int tc=1;tc<=T;tc++) {
			st = new StringTokenizer(br.readLine());
			String s = st.nextToken();
			int k = Integer.parseInt(st.nextToken());
			int pos = 0;
			for(int i=0;i<s.length();i++) {
				if(s.charAt(i)=='o') {pos = i;
					break;
				}
			}
			while(k-->0) {
				if(pos==0) pos = 1;
				else if(pos==1) pos = 0;
				else pos = 1;
			}
			System.out.println("#"+tc+" "+pos);
		}
	}
}

'Algorithms > SWEA' 카테고리의 다른 글

[SWEA] 주혁이의 복권 당첨  (0) 2025.11.25
[SWEA] 육십갑자  (0) 2025.11.22
[SWEA] 문자열 교집합  (0) 2025.11.22
[SWEA] 두 수의 덧셈  (0) 2025.11.21
[SWEA] 다솔이의 월급 상자  (0) 2025.11.21