문제 : https://www.acmicpc.net/problem/1193 



 import java.util.Scanner;

 public class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int input = scan.nextInt();

        String focus = "left";
        
        int left = 1;
        int right = 1;
        
        for(int i = 1 ; i < input ; i++) {
            if ("left".equals(focus)) {
                right ++;
                if(left ==1) {
                    focus = "right";
                } else {
                    left --;
                }

            } else if ("right".equals(focus)) {
                left ++;
                if(right == 1) {
                    focus = "left";
                } else {
                    right--;
                }
            }
        }
        System.out.println(left + "/" +right);
    } 
    
 }

+ Recent posts

"여기"를 클릭하면 광고 제거.