1 import java.util.Arrays; 2 import java.util.Comparator; 3 import java.util.HashMap; 4 import java.util.Map; 5 import java.util.Scanner; 6 7 public class Main{ 8 public static void main(String[]args){ 9 Map<String, Integer> Month2Int=new HashMap<String, Integer>(); 10 Month2Int.put("January", 1); 11 Month2Int.put("February", 2); 12 Month2Int.put("March", 3); 13 Month2Int.put("April", 4); 14 Month2Int.put("May", 5); 15 Month2Int.put("June", 6); 16 Month2Int.put("July", 7); 17 Month2Int.put("August", 8); 18 Month2Int.put("September", 9); 19 Month2Int.put("October", 10); 20 Month2Int.put("November", 11); 21 Month2Int.put("December", 12); 22 Map<Integer, String> int2Week=new HashMap<Integer, String>(); 23 int2Week.put(1, "Sunday"); 24 int2Week.put(2, "Monday"); 25 int2Week.put(3, "Tuesday"); 26 int2Week.put(4, "Wednesday"); 27 int2Week.put(5, "Thursday"); 28 int2Week.put(6, "Friday"); 29 int2Week.put(7, "Saturday"); 30 31 Date t=new Date(); 32 t.year=0; 33 t.month=1; 34 t.day=1; 35 int count=0; 36 while(t.year!=3001){ 37 buf[t.year][t.month][t.day]=count; 38 t.nextDate(); 39 count++; 40 } 41 42 Scanner in=new Scanner(System.in); 43 while(in.hasNext()){ 44 int day=in.nextInt(); 45 String month=in.next(); 46 int year=in.nextInt(); 47 int month_=Month2Int.get(month); 48 49 int x1=buf[year][month_][day]; 50 int x2=buf[2015][9][9]; 51 int c=x1-x2+3; 52 c=(c%7+7)%7; 53 c++; 54 System.out.println(int2Week.get(c)); 55 } 56 } 57 private static int isYeap(int x){ 58 if(x%4==0&&x%100!=0||x%400==0) return 1; 59 else return 0; 60 } 61 private static int[][]dayOfMonth={ 62 {0,0}, 63 {31,31}, 64 {28,29}, 65 {31,31}, 66 {30,30}, 67 {31,31}, 68 {30,30}, 69 {31,31}, 70 {31,31}, 71 {30,30}, 72 {31,31}, 73 {30,30}, 74 {31,31} 75 }; 76 private static class Date{ 77 int year; 78 int month; 79 int day; 80 void nextDate(){ 81 day++; 82 if(day>dayOfMonth[month][isYeap(year)]){ 83 day=1; 84 month++; 85 } 86 if(month>12){ 87 month=1; 88 year++; 89 } 90 } 91 } 92 private static int[][][]buf=new int[3001][13][32]; 93 }