UVA 12019 Java

import java.util.*;
import static java.lang.System.*;
public class main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int[] mon = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    String[] days = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
    int cases = sc.nextInt();
    for(int i =0; i < cases; i++)
    {
    	int m = sc.nextInt();
    	int d = sc.nextInt();
    	d += 4;
    	for(int j = 1; j < m; j++)
    	 d = d + mon[j-1];
    	System.out.println(days[d%7]);
    }
  }
};

留言

這個網誌中的熱門文章

C# 井字遊戲