编程介的小学生 2017-03-28 03:13 采纳率: 20.5%
浏览 624
已采纳

Burned Calendar

A year calendar is printed using the monospace font according to the following rules:

1) All spaces on the printed calendar are represented by the dot character (ASCII 46).

2) 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.

3) 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.

a. 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 a leap year 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 may look 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....
......................................................

A 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 contains integer numbers N and M (2 <= N, M <= 10), separated by spaces - the size of the piece. The following M lines contain N characters each - the piece of calendar.

Output

Output 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).

This problem contains multiple test cases!

The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.

The output format consists of N output blocks. There is a blank line between output blocks.

Sample Input

2

4 4
1..8
....
JUNE
1..8

3 2
1.7
...

Sample Output

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

0

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-04-06 15:46
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?