codeup 1929: Day of Week时间处理

Fastjson2升级指南:如何平滑迁移并避免兼容性问题 本文详细介绍了Fastjson2的升级指南,涵盖兼容性检查、性能调优及零停机迁移方案。通过实战案例展示如何避免常见问题,如日期格式严格校验和字段映射策略变化,并分享高性能配置技巧如JSONB二进制协议和内存池化。帮助开发者平滑迁移至Fastjson2,提升JSON处理效率。 阅读详情

1929: Day of Week

时间限制: 1 Sec   内存限制: 32 MB
献花: 339   解决: 104
[ 献花][ 花圈][ TK题库]

题目描述

We now use the Gregorian style of dating in Russia. The leap years are years with number divisible by 4 but not divisible by 100, or divisible by 400.
For example, years 2004, 2180 and 2400 are leap. Years 2004, 2181 and 2300 are not leap.
Your task is to write a program which will compute the day of week corresponding to a given date in the nearest past or in the future using today’s agreement about dating.

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
#define inf 0x3f3f3f
int month[13][2]= {{0,0},{31,31},{28,29},{31,31},{30,30},{31,31},{30,30},{31,31},{31,31},{30,30},{31,31},{30,30},{31,31}};
//month数组用来表示平年和闰年的每个月的天数,第一维表示月份,第二维0表示平年,1表示闰年
string monthname[13]={
    "",
    "January",
    "February",
    "March",
    "April",
    "May",
    "June",
    "July",
    "August",
    "September",
    "October",
    "November",
    "December"  };
string weekday[7]={
    "Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday"};
string ouweekday[7] = {
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
    "Sunday"
    };
bool judge(int y)//判断平闰年
{
    return (y%4==0&&y%100!=0)||(y%400==0);
}
int main()
{
    int a,b;
    string s;
    int m;
    while(cin>>a>>s>>b)
    {
        for(int i=1;i<=12;i++)
        {
            if(s==monthname[i])
                {
                    m=i;
                    break;
                }
        }
        int d=a+m*100+b*10000;
        int date1=d<20180422?d:20180422;
        int date2=d>20180422?d:20180422;
        int y1=date1/10000,m1=date1%10000/100,d1=date1%100;
        int y2=date2/10000,m2=date2%10000/100,d2=date2%100;
        int ans=0;
        while(y1<y2||m1<m2||d1<d2)//两个日期不相等就进行加一运算
        {
            d1++;
            if(d1>month[m1][judge(y1)])//如果小日期的天数大于该月的天数,进入下一个月,月份加一,置为下月1号
            {
                m1++;
                d1=1;
            }
            if(m1==13)//如果月份大于12,则进入下一年,月份置一
            {
                y1++;
                m1=1;
            }
            ans++;//累计天数
        }
        //cout<<ans<<endl;
        int cha=ans%7;
        if(d>20180422)//当题目所给时间比自己选定标准时间大时
        {
            cout<<weekday[cha]<<endl;
        }
        else//题目所给时间比自己选定时间小
        {
            if(cha==0)
            cout<<"Sunday"<<endl;
           else
        cout<<ouweekday[6-cha]<<endl;
        }

    }

    return 0;
}



输入

There is one single line contains the day number d, month name M and year number y(1000≤y≤3000). The month name is the corresponding English name starting from the capital letter.

输出

Output a single line with the English name of the day of week corresponding to the date, starting from the capital letter. All other letters must be in lower case.

样例输入

21 December 2012
5 January 2013

样例输出

Friday
Saturday
Dify 部署与使用 本文介绍了Dify社区版的快速部署指南,涵盖系统架构、环境配置和初始化流程。Dify采用微服务架构,通过Docker Compose一键部署8个核心容器,包括前端、后端、数据库等组件。部署过程包括克隆代码、配置环境变量和启动服务,首次启动需3-10分钟下载镜像。文章详细讲解了.env文件的配置要点,包括服务地址、数据库连接和向量存储设置,并提供了生产环境安全加固建议。最后通过访问/install页面完成管理员账号初始化,即可开始使用Dify构建AI应用。 阅读详情

相关推荐

SolidWorks草图绘制实战:如何用图片参考快速搞定智能小车底板设计

本文详细介绍了在SolidWorks中利用图片参考进行草图绘制的实战方法,以智能小车底板设计为例,帮助设计师快速将概念转化为精准三维模型。通过插入、对齐参考图片并高效描图,结合参数化约束与尺寸驱动,大幅提升设计效率和准确性,尤其适合新手入门与老手优化工作流。

rust6ferris的博客 217

《算法笔记》3.4小节——入门模拟->日期处理 问题 B: Day of Week

题目描述 We now use the Gregorian style of dating in Russia. The leap years are years with number divisible by 4 but not divisible by 100, or divisible by 400. For example, years 2004, 2180 and 2400 are leap. Years 2004, 2181 and 2300 are not leap. Your task i

天宝妈妈的博客 357

简易电梯控制系统设计(两层楼)(

(电子科技大学 数字系统实验二 结课验收项目 ) 题目要求:

m0_48801027的博客 1万+

算法学习——日期处理问题

问题 A: 日期差值 时间限制: 1 Sec 内存限制: 32 MB 题目描述 有两个日期,求两个日期之间的天数,如果两个日期是连续的我们规定他们之间的天数为两天。 输入 有多组数据,每组数据有两行,分别表示两个日期,形式为YYYYMMDD 输出 每组数据输出一行,即日期差值 样例输入 20130101 20130105 样例输出 5 解题思路 这种求日期之间相差天数...

程序媛的自学笔记 2157

S32K344 Bootloader实战:一个按键实现从Boot到App的无缝跳转(附完整代码)

本文详细介绍了基于NXP S32K344微控制器的Bootloader开发实战,重点解析如何通过一个硬件按键实现从Boot到App的可靠跳转。内容涵盖内存分区规划、中断向量表重映射、外设初始状态管理等核心要素,并提供了完整的代码示例和调试技巧,适用于汽车电子和工业控制等高可靠性应用场景。

weixin_29192365的博客 307

VisionMaster字符检测避坑指南:为什么你的缺陷检测总误判?7个参数陷阱详解

本文深入剖析了海康VisionMaster在字符缺陷检测中导致误判的7个关键参数陷阱,包括二值化参数、最小字符面积与宽度、字符极性及缺陷判决参数等。通过药品喷码和PCB丝印等实战案例,提供了系统的调试心法与工作流,帮助工程师精准调参,有效降低误判率,提升检测稳定性。

rust6ferris的博客 1097

算法笔记入门(算法模拟日期处理)——问题 B: Day of Week

题目描述 We now use the Gregorian style of dating in Russia. The leap years are years with number divisible by 4 but not divisible by 100, or divisible by 400. For example, years 2004, 2180 and 2400 are leap. Years 2004, 2181 and 2300 are not leap. Your task i

qq_52071659的博客 379

类银河恶魔城学习记录1-1 Player状态机的搭建 P28

什么是状态机?一篇文章就够了 - 知乎说实话,目前并不能深入理解状态机的奇妙之处(当然,我觉得状态机作为教程的重要组成部分是不得不理解的,所以以下我会对游戏教程内的状态机做一些我认为的解释,如有错误,请多包涵)

Homura_的博客 2338

例2.4 Day of Week - 九度教程第7题(日期类问题)

例2.4 Day of Week(九度教程第7题) 题目 时间限制:1 秒 内存限制:32 兆 特殊判题:否 题目描述: We now use the Gregorian style of dating in Russia. The leap years are years with number divisible by 4 but not divisible by 100, or div...

weixin_39450145的博客 358

Windows Server下OnlyOffice Workspace社区版安装避坑指南(含局域网邮箱配置)

本文详细介绍了在Windows Server环境下部署OnlyOffice Workspace社区版的完整流程,特别针对企业内网环境中的邮箱配置和端口冲突等常见问题提供了实用解决方案。通过硬件资源配置建议、软件环境检查清单以及内网邮箱系统搭建方案对比,帮助用户高效搭建企业级协作平台,实现团队协作的无缝对接。

weixin_29231263的博客 449

ANSYS HFSS 中的相控天线阵列仿真方法

相控天线阵列系统广泛使用,从国防雷达应用到商业 5G 应用。设计这些天线阵列涉及复杂的数学运算,需要全波仿真。Ansys HFSS 全场 3D 电磁仿真软件可以在合理的时间内以较低的计算成本仿真复杂的相控阵天线系统,同时考虑复杂激励、环境(即附近的天线)和平台对其性能的影响。本博客介绍了可用于有效仿真相控天线阵列的不同方法。以下是不同仿真方法的简要概述,视频链接中提供了完整的演示。ANSYS HFSS 提供 4 种不同的相控天线阵列仿真方法:1) 晶胞-无限阵列。

jkh920184196的博客 4246

Codeup-1929: Day of Week

题目描述 We now use the Gregorian style of dating in Russia. The leap years are years with number divisible by 4 but not divisible by 100, or divisible by 400. For example, years 2004, 2180 and 2400 are ...

小小白~ 310

Ta-Lib源码解析(三):蜡烛图指标 (Candlestick Indicator) #(附Python重构代码和示意图)(补充中)

蜡烛图指标为识别K线形态的指标,笔者认为重点在于定义方式所提供的思路,背后的投资逻辑可以借鉴但不建议直接参考文档的翻译内容和源码逻辑存在不一致的现象,笔者分别列出中文百科中的定义和源码实际逻辑,供大家参考技术分析理论中的一些模糊词,ta-lib中给出了精确的定义源码

量化就是探索生活 3253

codeup 1929 | Day of Week

问题 B: Day of Week 时间限制 : 1.000 sec内存限制 : 32 MB 解决 : 724提交 : 2328 题目描述 We now use the Gregorian style of dating in Russia. The leap years are years with number divisible by 4 but not divi...

weixin_43787043的博客 395

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

1929 Problem B Day of Week

问题 B: Day of Week 时间限制:1 Sec内存限制:32 MB 题目描述 We now use the Gregorian style of dating in Russia. The leap years are years with number divisible by 4 but not divisible by 100, or divisible by 400...

漫浸天空的雨色的备忘录~ 994

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

C/C++[codeup 1929,]日期处理

1929题目描述:day of week We now use the Gregorian style of dating in Russia. The leap years are years with number divisible by 4 but not divisible by 100, or divisible by 400. For example, years 2004, 2...

机器会学习的博客 407

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

C/C++[codeup 1929,]今天星期几

1929题目描述:day of week We now use the Gregorian style of dating in Russia. The leap years are years with number divisible by 4 but not divisible by 100, or divisible by 400. For example, years 2004, 2...

机器会学习的博客 768

codeup墓地目录(算法笔记习题刷题笔记)

在线codeup contest 地址:http://codeup.cn/contest.php Contest100000575 - 《算法笔记》3.1小节——入门模拟-&gt;简单模拟 1814 Problem A 剩下的树 1817 Problem B A+B 1906 Problem C 特殊乘法 2036 Problem D 比较奇偶数个数 6116 Probl...

fantasydreams的专栏 1万+

小白入门!提升代码能力!【算法】入门篇(1)—— 入门模拟

写在前面: 大家好,我是贝贝。昵称 "贝贝今天AC了吗" 是为了督促自己码题,相信圈子里的大家伙都懂喇。我热爱技术、热爱开源、热爱编程。 我始终相信:技术是开源的,知识是共享的。 博客内均是我平常学习的总结,在便于自己往后回顾之余,也希望向大家分享知识。 每篇文章我都是负责任地总结着,相信您看几篇文章就会发现我的乖巧。 目前在总结比较基础入门的知识。如果喜欢,不妨关注,我们...

weixin_43787043的博客 714

1929 Problem B Day of Week

问题 B: Day of Week 时间限制: 1 Sec 内存限制: 32 MB 献花: 164 解决: 64 [献花][花圈][TK题库] 题目描述 We now use the Gregorian style of dating in Russia. The leap years are years with number divisible by 4 but not divis

fantasydreams的专栏 801

codeup——问题 B: Day of Week(按照蔡勒公式写)

问题 B: Day of Week 时间限制: 1 Sec  内存限制: 32 MB 提交: 566  解决: 161 [提交][状态][讨论版][命题人:外部导入] 题目描述 We now use the Gregorian style of dating in Russia. The leap years are years with number divisible by 4 but not...

写东西仪式感极强(其实拖延症晚期晚期)的大龄小白 546

问题 : Day of Week

问题 : Day of Week时间限制: 1 Sec  内存限制: 32 MBhttp://218.198.32.182/problem.php?cid=1071&amp;pid=7题目描述We now use the Gregorian style of dating in Russia. The leap years are years with number divisible by 4 ...

liu344439833的博客 1483

codeup100000578B-DayofWeek

Day of Week 题目 We now use the Gregorian style of dating in Russia. The leap years are years with number divisible by 4 but not divisible by 100, or divisible by 400. For example, years 2004, 2180 an

R11happy的博客 675

Day of Week

问题: We now use the Gregorian style of dating in Russia. The leap years are years with number divisible by 4 but not divisible by 100, or divisible by 400. For example, years 2004, 2180 and 2400 are ...

iteye_16074的博客 299

九度OJ-1043:Day of Week

题目描述: We now use the Gregorian style of dating in Russia. The leap years are years with number divisible by 4 but not divisible by 100, or divisible by 400. For example, years 2004, 2180 and 2400

听风就是雨 484

code up Day of Week

题目描述 We now use the Gregorian style of dating in Russia. The leap years are years with number divisible by 4 but not divisible by 100, or divisible by 400. For example, years 2004, 2180 and 2400 are leap. Years 2004, 2181 and 2300 are not leap. Your task

mglcms的博客 257
上一篇: codeup 1928 日期差值
下一篇: codeup 装箱问题
Yolo_Fs
博客等级 码龄9年 41粉丝 46原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值