时间限制:1 秒

内存限制:32 兆

特殊判题:

提交:7336

解决:2563

题目描述:

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.

输入:

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.

样例输入:
9 October 2001
14 October 2001
样例输出:
Tuesday
Sunday
提示:

Month and Week name in Input/Output:
January, February, March, April, May, June, July, August, September, October, November, December
Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday

已知年月日,计算星期的公式有两个,一个是蔡勒公式,另一个就是基姆拉尔森计算公式。

具体的我也就不写了,大家可以百度。O(∩_∩)O哈哈~

我用的是基姆拉尔森计算公式。可以试着用蔡勒公式做下。但是那个比这个麻烦一点,因为还要计算出世纪c。

//Asimple
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <limits.h>
#define INF 0x7fffffff
using namespace std;
const int maxn = ;
typedef long long ll;
int year, days;
string moths[] = {"January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December"};
string str;
string weeks[]={"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday","Sunday"}; int main(){
while( cin >> days >> str >> year ){
int m;
for(int i=; i<; i++){
if( str == moths[i] ){
m = i + ;
break;
}
}
if( m == || m == ){
m += ;
year --;
}
int a = (days + * m + * (m + ) / + year + year / - year / + year / ) % ;
cout << weeks[a] << endl;
}
return ;
}

最新文章

  1. ASP.NET Core 中文文档 第二章 指南(4.8)添加新的字段
  2. 各种排序学习归纳总结(Java)
  3. Angulajs系列-01-入门
  4. IntelliJ IDEA快捷键和常用设置
  5. in_array 的第三个参数strict设置为 true
  6. pysam - 多种格式基因组数据(sam/bam/vcf/bcf/cram/&hellip;)读写与处理模块(python)
  7. examine self thrice a day2016
  8. Visual Studio 中 Tab 转换为空格的设置
  9. 比特币钱包应用breadwallet源码
  10. BAT CMD 批处理文件脚本 -1
  11. DelphiXE Android的所有权限按照分类总结说明
  12. MongoDB - Installing MongoDB on Windows
  13. Oracle 10g DataGuard手记之基础配置
  14. Listener与Filter
  15. 分布式计算框架学习笔记--hadoop工作原理
  16. spring boot 包jar运行
  17. Android小知识汇总
  18. 使用ajax实现form表单的submit事件
  19. 谈谈你对MVC的理解
  20. Pycharm创建Django项目并访问Django

热门文章

  1. iOS - (调用系统本机打电话功能)
  2. hibernate3与ehcache-2.8.3配合使用,在多个SessionFactory实例的情况下出现&ldquo;Another unnamed CacheManager already exists in the same VM&rdquo;问题
  3. Java基础之写文件——缓冲区中的多条记录(PrimesToFile3)
  4. 原来现在很多人都用SignalR来实现Chat Room
  5. SqlServer跨库查询
  6. 2的m次方 内存对齐
  7. zabbix监控windows主机网卡流量
  8. HDU 2993 MAX Average Problem(斜率优化)
  9. CSS_03_04_CSS伪元素选择器
  10. 夺命雷公狗---Thinkphp----13之前台的头尾分离和导航分离