USACO-Section1.1 Friday the Thirteenth
来源:互联网 发布:js fetch api 编辑:程序博客网 时间:2024/06/05 19:39
Friday the Thirteenth
本题主要内容是根据所给日期,计算星期几,再简化,就是计算两个日期间的间隔,这时用儒略日计算就比较方便。儒略日的计算方法可另行查找。
代码如下:
/*ID: xhzdcyy1PROB: fridayLANG: C++ */#include <iostream>#include <fstream>#include <string>using namespace std;int main(){ ofstream fout ("friday.out"); ifstream fin ("friday.in"); int n; fin>>n; int arr[7]={0}; int jd; int y,m,day,a,year,month; year=1900; month=1; day=13; while(year<1900+n){ a=(14-month)/12; y=year+4800-a; m=month+12*a-3; jd=(153*m+2)/5+365*y+y/4-y/100+y/400+day-32045; ++arr[(jd+2)%7]; if(month==12){ month=1; ++year; } else{ ++month; } } for(int i=0;i<7;i++){ fout<<arr[i]; if(i!=6) fout<<" "; } fout<<endl; return 0; }
阅读全文
0 0
- USACO-Section1.1 Friday the Thirteenth [日期]
- USACO-Section1.1 Friday the Thirteenth [日期]
- USACO-Section1.1 Friday the Thirteenth
- USACO-Section1.1 Friday the Thirteenth
- USACO-Section1.1 Friday the Thirteenth
- USACO-Section1.1 Friday the Thirteenth[日期]
- USACO Section1.1 Friday the Thirteenth
- USACO-Section1.1 Friday the Thirteenth【泰勒公式】
- USACO之Section1.1.3 Friday the Thirteenth
- Friday the Thirteenth-section1.1
- USCAO-Section1.1 Friday the Thirteenth
- Friday the Thirteenth(USACO)
- usaco--Friday the Thirteenth
- [USACO] Friday the Thirteenth
- usaco Friday the Thirteenth
- USACO Friday the Thirteenth
- USACO:Friday the Thirteenth
- USACO -Friday the Thirteenth
- MyEclipse 清理项目缓存的几大方法
- 实现用户登录时若没有输入用户名,给出用户名不能为空的提示,若没有输入密码,给出密码不能为空的提示
- 快捷键查看Emacs源码
- BZOJ 3158: 千钧一发 网络流
- 前台开发总结07——20170525
- USACO-Section1.1 Friday the Thirteenth
- boost format用法总结
- 【51Nod】1118 机器人走方格
- 二叉树的最小深度
- 小白项目初尝试第二弹——飞机大战中期
- 关于用公网IP访问不了服务器的问题
- 淘淘商城系列——发布dubbo服务
- linux pppd-GPRS和以太网同时在线,解决拨号默认网关
- Python(5) Image和Ndarray互相转换