跳到正文

题解

题解:P10983 [蓝桥杯 2023 国 Python A] 跑步计划

SpriteQAQ约 2 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年5月19日
篇幅
约 2 分钟
题目
P10983

版本

  1. v1当前

1,思路

遍历 20232023 年中的 365365 天。 月份为外层循环,天数为内层循环。 判断当天日期是否出现 11 来确定路程加几, 具体条件 ( 可以手打,可以巧妙判断,这里我选择手打 ) 如下:

  1. 是否是周一,cnt % 7 == 1 ;
  2. 月份是否含 11 ,month == 1 or month == 10 or month == 11 or month == 12 ;
  3. 天数是否含 11 ,(day >= 10 and day <= 19) or day == 1 or day == 21 or day == 31 。

2,完整代码

Python
d_in_m = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
# 打表月份天数
cnt = 7
# cnt用于查看今天是不是周一
ans = 0
# ans为路程总和
for month in range(12):
    #遍历每个月份
    month += 1
    tmp = d_in_m[month]
    #tmp用于临时储存当月天数
    for day in range(tmp):
        day += 1
        if cnt % 7 == 1 or month == 1 or month == 10 or month == 11 or month == 12 or (day >= 10 and day <= 19) or day == 1 or or day == 21 or day == 31:
            ans += 5
        else:
            ans += 1
        cnt += 1
        # 周数加1
print(ans)
# 完结撒花
原文