📄 4044649_wa.cpp
字号:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char piece[11][11];
int n, m;
int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int now = 1;
int isleap(int year)
{
return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0);
}
class Calendar
{
private:
char str[29][74];
int year;
public:
Calendar(int year)
{
int i, j;
for (i = 0; i < 28; i++)
{
for (j = 0; j < 73; j++)
{
str[i][j] = '.';
}
str[i][j] = '\0';
}
strncpy(&str[1][2], "JANUARY", 7);strncpy(&str[1][20], "FEBRURY", 7);strncpy(&str[1][38], "MARCH", 5);strncpy(&str[1][56], "APRIL", 5);
strncpy(&str[10][2], "MAY", 3);strncpy(&str[10][20], "JUNE", 4);strncpy(&str[10][38], "JULY", 4);strncpy(&str[10][56], "AUGUST", 6);
strncpy(&str[19][2], "SEPTEMBER", 9);strncpy(&str[19][20], "OCTOBER", 7);strncpy(&str[19][38], "NOVEMBER", 8);strncpy(&str[19][56], "DECEMBER", 8);
for (int month = 1; month < 13; month++)
{
int maxday = days[month] + (month == 2 && isleap(year));
int offset = 0;
for (int day = 1; day <= maxday; day++)
{
int x, y;
x = (month - 1) / 4 * 9 + now + 1;
y = (month - 1) % 4 * 18 + offset + 1;
if (day > 9)
{
str[x][y] = day / 10 + '0';
str[x][y + 1] = day % 10 + '0';
}
else
{
str[x][y + 1] = day + '0';
}
now++;
if (now == 8)
{
now = 1;
offset += 3;
}
}
}
}
void print()
{
for (int i = 0; i < 28; i++)
{
puts(str[i]);
}
}
bool find()
{
int i, j, s, t;
for (i = 0; i <= 28 - m; i++)
{
for (j = 0; j <= 73 - n; j++)
{
bool fail = false;
for (s = 0; s < m; s++)
{
for (t = 0; t < n; t++)
{
if (piece[s][t] != str[i + s][j + t])
{
fail = true;
}
}
}
if (!fail) return true;
}
}
return false;
}
};
int main()
{
bool empty = true;
scanf("%d%d", &n, &m);
for (int i = 0; i < m; i++)
{
scanf("%s", piece[i]);
}
for (int year = 1900; year < 2101; year++)
{
Calendar c = Calendar(year);
//c.print();
if (c.find())
{
empty = false;
printf("%d\n", year);
}
}
empty && puts("0");
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -