每日一九度之 题目1043:Day of Week
时间限制: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 ;
}
每日一九度之 题目1043:Day of Week的更多相关文章
- 每日一九度之 题目1076:N的阶乘
时间限制:3 秒 内存限制:128 兆 特殊判题:否 提交:7601 解决:2749 题目描述: 输入一个正整数N,输出N的阶乘. 输入: 正整数N(0<=N<=1000) 输出: 输入可 ...
- 每日一九度之 题目1042:Coincidence
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3007 解决:1638 题目描述: Find a longest common subsequence of two strings. 输入 ...
- 每日一九度之 题目1041:Simple Sorting
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4883 解决:1860 题目描述: You are given an unsorted array of integer numbers. ...
- 每日一九度之 题目1040:Prime Number
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6732 解决:2738 题目描述: Output the k-th prime number. 输入: k≤10000 输出: The k- ...
- 每日一九度之 题目1038:Sum of Factorials
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2109 解决:901 题目描述: John von Neumann, b. Dec. 28, 1903, d. Feb. 8, 1957, ...
- 每日一九度之 题目1039:Zero-complexity Transposition
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3372 解决:1392 题目描述: You are given a sequence of integer numbers. Zero-co ...
- 每日一九度之 题目1033:继续xxx定律
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5502 解决:1351 题目描述: 当n为3时,我们在验证xxx定律的过程中会得到一个序列,3,5,8,4,2,1,将3称为关键数, ...
- 每日一九度之 题目1031:xxx定律
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6870 解决:4302 题目描述: 对于一个数n,如果是偶数,就把n砍掉一半:如果是奇数,把n变成 3*n+ 1后砍掉一半,直到该数 ...
- 每日一九度之 题目1030:毕业bg
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2046 解决:894 题目描述: 每年毕业的季节都会有大量毕业生发起狂欢,好朋友们相约吃散伙饭,网络上称为“bg”.参加不同团体的b ...
随机推荐
- 误卸载python2.4导致yum不能用后的修复
去 http://mirrors.ustc.edu.cn/centos/或者镜像下载如下包,版本不一定非常一致 python-2.4.3-56.el5.x86_64.rpmpython-devel-2 ...
- RAC GI安装,报"Task resolv.conf Integerity"验证失败
安装12.1.0.2 rac测试环境的时候,报"Task resolv.conf Integerity"验证失败 解决方案: 因为测试环境,没有使用DNS,删除resolv.con ...
- SQL2008 R2 SP3中使用pivot实现行转列
同事遇到一个问题,怎么实现行转列,参考了别人的示例,我是这样解决的. 创建数据源: create table #temp ( objectid int, sitename ), cities ), p ...
- 从零开始攻略PHP(6)——代码重用与函数编写的一些注意事项
一个新的项目是这样创建的:它将已有的可重新利用的组件进行组合,并将新的开发难度降低到最小. 代码重用的好处:降低成本.提升可靠性和一致性. 1.使用require()和include()函数 使用一条 ...
- Leetcode: Self Crossing
You are given an array x of n positive numbers. You start at point (0,0) and moves x[0] metres to th ...
- SQL 数据库备、还,附、分,数据查询,聚合函数
认识数据库备份和事务日志备份 数据库备份与日志备份是数据库维护的日常工作,备份的目的是在于当数据库出现故障或者遭到破坏时可以根据备份的数据库及事务日志文件还原到最近的时间点将损失降到最低点. 数据库备 ...
- java 选择排序法
public class Test3 { /**@author shaobn * @param 选择排序:将a.length - i个元素分别和第i个元素相比较,小的话就将值调换.依次递减进行排列 * ...
- paper 62:高斯混合模型(GMM)参数优化及实现
高斯混合模型(GMM)参数优化及实现 (< xmlnamespace prefix ="st1" ns ="urn:schemas-microsoft-com:of ...
- MVC权限管理系统dwpro项目分配按钮没有显示的问题
问题如下: 修改如下: 或者(原因为这个两个地方名要一致,大小写也要注意): 效果图:
- java 虚拟机工具
jps 命令 可以查询开启了rmi服务的远程虚拟机进程状态. -v jvm参数. jstat -gcutil命令 [cangyue@/System/Library/Frameworks/JavaVM. ...