编程介的小学生 2016-12-20 14:50 采纳率: 20.5%
浏览 784
已采纳

Burned Calendar

Description

A year calendar is printed using the monospace font according to the following rules:
All spaces on the printed calendar are represented by dots (ASCII 46).
Every month occupies a rectangle of 17 by 8 characters, with the name of the month written in all capital letters starting from the 2nd character of the first line.
All days of the months are printed in 4, 5, or 6 columns 2 characters wide and 7 characters high, with one space between the columns. The first day of the week is Monday.
Months of the year are arranged in the three rows separated by horizontal and vertical lines of spaces. Each row contains four months. The calendar margins are of 1 space from all sides. Therefore, the whole calendar has size of 73 by 28 characters.

Note that January 1st, 1900 was Monday. Also note that the year is a leap year if its number is divisible by 4 and not divisible by 100, or divisible by 400. For example, a part of the printed calendar from October to December 2002 looks like this:
.OCTOBER...........NOVEMBER..........DECEMBER.........

....7.14.21.28........4.11.18.25........2..9.16.23.30.

.1..8.15.22.29........5.12.19.26........3.10.17.24.31.

.2..9.16.23.30........6.13.20.27........4.11.18.25....

.3.10.17.24.31........7.14.21.28........5.12.19.26....

.4.11.18.25........1..8.15.22.29........6.13.20.27....

.5.12.19.26........2..9.16.23.30........7.14.21.28....

.6.13.20.27........3.10.17.24........1..8.15.22.29....

......................................................

The calendar was printed and then burned, with only a small rectangular piece left. Your program must determine to which of years from 1900 to 2100 this piece could belong.
Input

The first line of the input file contains integer numbers N and M - the sizes of the piece, separated by spaces. The following M lines contain N characters each - the piece of calendar. 2 <= N, M <= 10
Output

Output file must contain an ordered list of year numbers, one year per line. If given piece could not belong to any calendar, output must contain a single integer 0 (zero).
Sample Input

4 4
1..8
....
JUNE
1..8
Sample Output

1903
1914
1925
1931
1942
1953
1959
1970
1981
1987
1998
2009
2015
2026
2037
2043
2054
2065
2071
2082
2093
2099

  • 写回答

1条回答 默认 最新

  • threenewbee 2016-12-20 16:23
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 Python安装cvxpy库出问题
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥15 python天天向上类似问题,但没有清零
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 C#调用python代码(python带有库)
  • ¥15 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?