1.1 Friday the Thirteenth
2019独角兽企业重金招聘Python工程师标准>>>
以前也听说过黑色星期五,既是13号,又是星期五,这似乎这是个不详的日子,这个题目要我们通过计算了解一下黑色星期五是否有特别之处:计算是13号又是星期五的天数,以及13号,其他六天的天数,看看黑色星期五的天数是否特别些。要求计算从1900年1月1号开始,到1990+n-1年12月31号结束。已知1900年1月1号是星期一,要注意考虑平年闰年。输入为一个小于400的非负整数n,输出为7个不同天的天数。
/*
ID: whutzha1
PROG: friday
LANG: C++
*/
#include<fstream>
using namespace std;
ifstream cin("friday.in");
ofstream cout("friday.out");
int main()
{int year=1900;int month_day,date,month;date=(13-1+1)%7;int arr[7];int i,n;bool leap;for (i=0;i<7;i++) arr[i]=0;cin>>n;arr[date]++;while (year<1900+n){month=1;if((year%4==0&&year%100!=0)||year%400==0) leap=true;else leap=false;while(month<=12){switch (month){case 4:case 6:case 9:case 11: month_day=30;break; case 1:case 3:case 5:case 7:case 8:case 10:case 12: month_day=31;break;case 2: if (leap) month_day=29;else month_day=28; break;default: break;}month=month++;date=(date+month_day)%7;arr[date]++;}year++;}arr[date]--;for (i=6;i<12;i++){ cout<<arr[i%7]<<' ';}cout<<arr[5]<<endl;return 0;
}
百度了一下,黑色星期五之所以为黑色星期五,只是因为在西方国家中星期五和13都是不吉利的数字,而这两个不幸的数字叠加在一起,就成了大大的不幸,所以这样的日子被称为黑色星期五!而事实上,这个黑色星期五在天数上也没什么特别之处,和其他的天的天数差不多罢了!
转载于:https://my.oschina.net/u/585691/blog/66378
1.1 Friday the Thirteenth相关推荐
- USACO 1.1 Friday the Thirteenth
题目来源:USACO 1.1 原题目: Friday the Thirteenth Is Friday the 13th really an unusual event? That is, does ...
- Friday the Thirteenth 黑色星期五
** Friday the Thirteenth 黑色星期五 ** 解题思路来自NOCOW 题目: 13 号又是星期五是一个不寻常的日子吗? 13 号在星期五比在其他日少吗?为了回答这个问题,写一个程 ...
- USACO—1.1.3 Friday the Thirteenth 黑色星期五
题目描述: 1.1.3 Friday the Thirteenth 黑色星期五 (friday.pas/c/cpp) 13号又是一个星期五.13号在星期五比在其他日子少吗?为了回答这个问题,写一个程序 ...
- USACO黑色星期五Friday the Thirteenth
黑色星期五Friday the Thirteenth 嗯,虽然很水,但细节是真的多. 我闰年判断错了而且while循环都忘了(伤心) 题目描述 13号又是一个星期五.13号在星期五比在其他日子少吗?为 ...
- 黑色星期五Friday the Thirteenth
题目描述 13号又是一个星期五.13号在星期五比在其他日子少吗?为了回答这个问题,写一个程序,要求计算每个月的十三号落在周一到周日的次数.给出N年的一个周期,要求计算1900年1月1日至1900+N- ...
- USACO 1.0_Friday the Thirteenth
2019独角兽企业重金招聘Python工程师标准>>> 還好還好蛋沒有粉 /* NAME: zfb2 LANG: C++ TASK: friday */#include <io ...
- 洛谷P1202 [USACO1.1]黑色星期五Friday the Thirteenth
题目描述 13号又是一个星期五.13号在星期五比在其他日子少吗?为了回答这个问题,写一个程序,要求计算每个月的十三号落在周一到周日的次数.给出N年的一个周期,要求计算1900年1月1日至1900+N- ...
- [USACO1.1]黑色星期五Friday the Thirteenth
https://www.luogu.org/problemnew/show/P1202 又学了一招重载++ /* *@Author: STZG *@Language: C++ */ #include ...
- 洛谷 P1202 模拟 - 黑色星期五 Friday the Thirteenth
[题目描述] 13号又是一个星期五.13号在星期五比在其他日子少吗?为了回答这个问题,写一个程序,要求计算每个月的十三号落在周一到周日的次数.给出N年的一个周期,要求计算1900年1月1日至1900+ ...
最新文章
- 机器学习数据整合+pandas方法astype、merge、drop、to_numeric、concat等
- Objective C 链式调用
- python横向柱状图-python绘制横向水平柱状条形图Bar
- Java 修饰符、运算符笔记总结
- Linux查询系统信息
- 禁用笔记本键盘_如何禁用/启用笔记本内置键盘?
- 使用Arquillian和LocalStack脱机测试AWS云堆栈
- 4.24口语习语 听力复习
- Python基础之内置函数(二)
- 机器视觉之表面缺陷检测
- hdu 6184 Counting Stars(三元环计数)
- 如何将pdf转换成txt转换器破解版
- java pkcs8格式的私钥_RSA加密解密中pkcs1与pkcs8格式私钥互相转换
- 减肥--应该是种轻松愉快的经历
- c语言小车程序,循迹小车的C语言程序(带注释)
- KVell: the Design and Implementation of a Fast Persistent Key-Value Store
- 麻省理工MIT计算机课程表
- oracle 毫秒时间换mysql_Mysql与Oracle常用时间格式的转换
- pe系统如何读取手机_什么是otg(pe系统如何读取手机)
- Java利用Ant包进行解压缩文件