zoukankan      html  css  js  c++  java
  • CCF-CSP题解 201503-3 节日

    模拟题。

    良心出题人并没有(y_1>y_2)的样例。注意闰年的处理。

    #include <bits/stdc++.h>
    
    using namespace std;
    
    int dayOfMonth[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    
    bool isLunar(int year)
    {
        return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
    }
    
    int calendar[210][13][32];
    
    int main()
    {
        for (int year = 1850, weekday = 2; year <= 2050; year++)
        {
            dayOfMonth[2] = isLunar(year) ? 29 : 28;
            int yyear = year - 1850;
            for (int month = 1; month <= 12; month++)
            {
                for (int day = 1; day <= dayOfMonth[month]; day++)
                {
                    calendar[yyear][month][day] = weekday;
                    weekday = weekday % 7 + 1;
                }
            }
        }
    
        int a, b, c, y1, y2;
        scanf("%d%d%d%d%d", &a, &b, &c, &y1, &y2);
    
        for (int year = y1; year <= y2; year++)
        {
            dayOfMonth[2] = isLunar(year) ? 29 : 28;
            int yyear = year - 1850;
            int month = a;
            int cnt = 0, dday = 0;
            for (int day = 1; day <= dayOfMonth[month] && cnt < b; day++)
            {
                if (calendar[yyear][month][day] == c)
                    cnt++, dday = day;
            }
            if (cnt == b)
                printf("%04d/%02d/%02d
    ", year, month, dday);
            else
                printf("none
    ");
        }
    
        return 0;
    }
    
  • 相关阅读:
    盒子模型中问题
    outline
    高度自动相等方法
    正则表达式
    绝对定位 相对定位
    replace 使用函数作为第二参数
    float 浮动
    line-height 行高
    元素隐藏
    现代浏览器内部
  • 原文地址:https://www.cnblogs.com/acboyty/p/11479075.html
Copyright © 2011-2022 走看看