본문 바로가기

백준

BOJ_9655 돌 게임

백준 링크 : https://www.acmicpc.net/problem/9655

 

import java.util.Random;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        int arr [] = {1,3};
        int num;
        String turn ="";
        while(count >0){
            Random random = new Random();
            if(count <3){
                num=arr[0];
            }else num=arr[random.nextInt(2)];
            turn = "SK";
            count= count - num;

            if(count ==0) break;

            if(count <3){
                num=arr[0];
            }else num=arr[random.nextInt(2)];
            turn ="CY";
            count= count - num;

            if(count ==0) break;
        }
        System.out.println(turn);

    }
}

'백준' 카테고리의 다른 글

BOJ_1515 수 이어쓰기  (0) 2023.01.24
BOJ_1446 지름길  (0) 2023.01.24
BOJ_4659 비밀번호 발음하기  (0) 2023.01.24
BOJ_1406 에디터  (0) 2023.01.16
BOJ_1158 요세푸스 문제  (0) 2023.01.16