본문으로 바로가기
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

백준알고리즘


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


import java.util.Scanner;
//https://www.acmicpc.net/problem/1924
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String[] output = new String[13];
        int[] mdays = new int[13];
        mdays[1] = mdays[3] = mdays[5] = mdays[7] = mdays[8] = mdays[10] = mdays[12] = 31;
         mdays[4] = mdays[6] = mdays[9] = mdays[11] = 30;
         mdays[2] = 28;
        
        int M = scan.nextInt();
        int D = scan.nextInt();
        
        int totalDay = 0;
        
        for(int month=1; month < M; month++) {
            if(M == 1) {
                
                break;
            }
            
            totalDay += mdays[month];
        }
        totalDay += D;
        int result = totalDay % 7;
        switch(result) {
            case 1:
                System.out.println("MON");
                break;
            
            case 2:
                System.out.println("TUE");
                break;
                
            case 3:
                System.out.println("WED");
                break;
                
            case 4:
                System.out.println("THU");
                break;
                
            case 5:
                System.out.println("FRI");
                break;
                
            case 6:
                System.out.println("SAT");
                break;
                
            case 0:
                System.out.println("SUN");
                break;
        }
    }
    
}