C语言问题 : Checking the Calendar

Checking the Calendar

You are given names of two days of the week.

Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to the second day of the week you are given. Both months should belong to one year.

In this problem, we consider the Gregorian calendar to be used. The number of months in this calendar is equal to 12. The number of days in months during any non-leap year is: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31.

Names of the days of the week are given with lowercase English letters: "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".

Input

The input consists of two lines, each of them containing the name of exactly one day of the week. It's guaranteed that each string in the input is from the set "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".

Output

Print "YES" (without quotes) if such situation is possible during some non-leap year. Otherwise, print "NO" (without quotes).

Examples

Input

monday
tuesday

Output

NO

Input

sunday
sunday

Output

YES

Input

saturday
tuesday

Output

YES

Note

In the second sample, one can consider February 1 and March 1 of year 2015. Both these days were Sundays.

In the third sample, one can consider July 1 and August 1 of year 2017. First of these two days is Saturday, while the second one is Tuesday.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int f(char *);
int main()
{
    int b[2], sum;
    sum = -1;
    char a[2][20];
    scanf("%s", a[0]);
    scanf("%s", a[1]);
    b[0] = f(a[0]);
    b[1] = f(a[1]);
    if(b[0] >= b[1])  sum = b[0] - b[1];
    else sum = b[1] - b[0];
    if(sum == 0 || sum == 2 || sum == 3)  printf("YES\n");
    else  printf("NO\n");
    return 0;
}
int f(char *a)
{
    int b;
    if     (strcmp(a, "monday"))     b = 1;
    else if(strcmp(a, "tuesday"))    b = 2;
    else if(strcmp(a, "wednesday"))  b = 3;
    else if(strcmp(a, "thursday"))   b = 4;
    else if(strcmp(a, "friday"))     b = 5;
    else if(strcmp(a, "saturday"))   b = 6;
    else if(strcmp(a, "sunday"))     b = 7;
    return b;
}

 代码提交是Wrong answer ,原因:

1. 下方函数的strcmp使用错误,当所比较的字符串相等时,其返回值为0,我误以为和if函数一样,相等时为1

2. sum的计算不能够只计算时间间隔,一个星期的两天可以有:从前面向后数和从后面向前面数两种方式,所以两天的间隔可能有两个结果,此处只能用后一天减前一天

改正代码如下:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int f(char *);
int main()
{
    int b[2], sum;
    sum = -1;
    char a[2][20];
    scanf("%s", a[0]);
    scanf("%s", a[1]);
    b[0] = f(a[0]);
    b[1] = f(a[1]);
    sum = b[1] - b[0];
    //计算后一天和前一天差几天,一定要用后一天减前一天!不要减反!!!
    if(sum < 0) sum += 7;//如果sum<0则进入下一个星期
    if(sum == 0 || sum == 2 || sum == 3)  printf("YES\n");
    //每个月有28或30或31天三种可能,相当于间隔0或2或3天,所以sum的三种结果符合要求
    else  printf("NO\n");
    return 0;
}
int f(char *a)
{
    int b;
    if     (strcmp(a, "monday") == 0)     b = 1;
    else if(strcmp(a, "tuesday") == 0)    b = 2;
    else if(strcmp(a, "wednesday") == 0)  b = 3;
    else if(strcmp(a, "thursday") == 0)   b = 4;
    else if(strcmp(a, "friday") == 0)     b = 5;
    else if(strcmp(a, "saturday") == 0)   b = 6;
    else if(strcmp(a, "sunday") == 0)     b = 7;
    return b;
}

 

<think>好的,用户现在问的是关于PyInstaller打包过程中出现的几个INFO信息,具体是3094、3123、3147、3148这几条。之前用户遇到了互斥选项的问题,现在可能已经解决了那个问题,但遇到了新的打包步骤的信息。用户可能想知道这些INFO信息的具体含义,以及打包过程是否正常进行。 首先,我需要回忆一下PyInstaller的工作流程。通常,PyInstaller打包分为几个阶段:Analysis、PYZ、PKG、EXE等。用户提到的这些INFO日志对应了不同的阶段。我需要逐步解释每个步骤的作用,让用户了解当前打包进行到哪一步,以及每个步骤的重要性。 然后,用户提到“Building PKG (CArchive) main_ui.pkg”,这里可能需要解释CArchive是什么,以及PKG文件的作用。用户可能对生成的pkg文件有疑问,或者想知道这个步骤是否成功。同时,用户可能想知道为什么会出现“Building because toc changed”,这里需要说明toc(Table of Contents)的作用,以及为何它的变化会触发重新构建。 接下来,我需要确保回答结构清晰,分步骤解释每个日志信息,并给出可能的建议或注意事项。比如,在Analysis阶段,PyInstaller分析依赖,用户可能需要检查是否有未正确导入的模块;在PYZ阶段,构建压缩的代码库,可能需要优化导入以减少打包大小;在PKG阶段,生成中间文件,可能需要关注是否有错误信息出现。 还要考虑用户可能的后续问题,比如打包时间过长,或者生成的pkg文件大小异常,所以在扩展建议中可以提到这些情况,并给出处理建议,比如排除不必要的文件,检查依赖项等。 最后,确保语言口语化,避免使用过于技术性的术语,让用户容易理解。同时,确认回答符合之前用户提到的格式要求,比如使用中文,结构清晰,分点说明等。</think>以下是PyInstaller打包过程中关键步骤的解析,对应你提供的日志信息: --- ### **1. Analysis阶段 (3094 INFO)** ```bash 3094 INFO: checking Analysis ``` - **作用**:PyInstaller正在分析你的Python脚本 - 递归扫描所有`import`语句 - 收集依赖的第三方库和本地模块 - 生成程序的依赖关系图 - **注意**:若此阶段卡顿,可能是代码中存在动态导入(如`__import__()`),需手动指定依赖 --- ### **2. PYZ阶段 (3123 INFO)** ```bash 3123 INFO: checking PYZ ``` - **作用**:创建`.pyz`压缩归档文件 - 将**所有Python字节码**(.pyc文件)压缩打包 - 包含主脚本及其依赖的纯Python库 - 排除二进制扩展(如`.pyd`, `.dll`,它们后续单独处理) - **优化技巧**:通过`--exclude-module`移除无用库可减小体积 --- ### **3. PKG阶段 (3147-3148 INFO)** ```bash 3147 INFO: checking PKG 3148 INFO: Building because toc changed 3148 INFO: Building PKG (CArchive) main_ui.pkg ``` - **核心机制**: - `toc` (Table of Contents):记录文件路径、类型、压缩方式等元数据 - `toc changed`表示依赖关系或文件内容有变动,触发重新打包 - **CArchive**:PyInstaller自有的加密压缩格式 - 将PYZ、二进制依赖、资源文件等整合为`.pkg` - 最终会被写入可执行文件的尾部 --- ### **4. 后续阶段(未显示但自动进行)** - **EXE构建**:将引导程序、PKG数据合并生成最终可执行文件 - **清理临时文件**:删除`build/`目录中的中间产物 --- ### **调试建议** 1. **查看详细日志**: ```bash pyinstaller --log-level=DEBUG your_script.py ``` 2. **检查警告**:关注`WARNING`开头的日志,常见问题: - 缺失图标文件(`--icon=xxx.ico`路径错误) - 隐藏控制台后未处理标准输出(GUI程序需加`--noconsole`) 3. **手动验证PKG**: ```python # 在Python中解压查看.pkg内容 from PyInstaller.archive import CArchive ar = CArchive('main_ui.pkg') ar.list() ``` 附:PyInstaller打包流程图 ``` [ 主脚本 ] --> Analysis --> 依赖图谱 ↓ PYZ(纯Python代码压缩包) ↓ PKG(整合二进制/资源文件) ↓ EXE(最终可执行文件) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值