USACO Friday the Thirteenth
2014-11-05 19:56
204 查看
模拟吧~~~
然后又发现这道题居然有公式~~~
·····
*蔡勒公式是一种计算任何一日属一星期中哪一日的算法,由蔡勒(Julius Christian Johannes Zeller)推算出。
公式都是基于公历的置闰规则来考虑。
公式中的符号含义如下:
w:星期
c:世纪(前两位数)
y:年(后两位数)
m:月(m 的取值范围为 3 至 14,即在蔡勒公式中,某年的 1、2月要看作上一年的 13、14月来计算,比如2003年1月1日要看作2002年的13月1日来计算)
d:日
[ ]:称作高斯符号,代表取整,即只要整数部份。
mod:同余(这里代表括号里的答案除以 7 后的余数)(请注意前面是负数取模的情况,取模只可以是正数)
若要计算的日期是在1582年10月4日或之前,公式则为
(因罗马教皇修改历法,把1582年10月4日的下一天改为1582年10月15日)
/* ID: xyl57681 PROG: friday LANG: C++ */ #include <iostream> #include <cstdio> #include <cstring> #include <fstream> using namespace std; long long a[8]; int year1[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31}, {0,31,29,31,30,31,30,31,31,30,31,30,31}}; int solve(int year){ if((year%4==0&&year%100!=0)||year%400==0) return 1; else return 0; } int main(){ ifstream fin ("friday.in"); <span style="white-space:pre"> </span>ofstream fout ("friday.out"); int N; fin>>N; int year=1900; memset(a,0,sizeof(a)); long long all_days=0; while(year!=1900+N){ for(int i=0;i<=11;i++){ a[(all_days+13)%7]++; all_days+=year1[solve(year)][i+1]; } year++; } fout<<a[6]<<" "<<a[0]<<" "<<a[1]<<" "<<a[2]<<" " <<a[3]<<" "<<a[4]<<" "<<a[5]<<endl; }
然后又发现这道题居然有公式~~~
·····
蔡勒公式
*蔡勒公式是一种计算任何一日属一星期中哪一日的算法,由蔡勒(Julius Christian Johannes Zeller)推算出。公式都是基于公历的置闰规则来考虑。
公式中的符号含义如下:
w:星期
c:世纪(前两位数)
y:年(后两位数)
m:月(m 的取值范围为 3 至 14,即在蔡勒公式中,某年的 1、2月要看作上一年的 13、14月来计算,比如2003年1月1日要看作2002年的13月1日来计算)
d:日
[ ]:称作高斯符号,代表取整,即只要整数部份。
mod:同余(这里代表括号里的答案除以 7 后的余数)(请注意前面是负数取模的情况,取模只可以是正数)
若要计算的日期是在1582年10月4日或之前,公式则为
(因罗马教皇修改历法,把1582年10月4日的下一天改为1582年10月15日)
相关文章推荐
- luogu1202 [USACO1.1]黑色星期五Friday the Thirteenth
- USACO-Section1.1 Friday the Thirteenth[日期]
- Friday the Thirteenth(黑色星期五) USACO
- USACO1.1.3 Friday the Thirteenth (friday)
- USACO section 1.1 Friday the Thirteenth
- luogu1202 [USACO1.1]黑色星期五Friday the Thirteenth
- USACO 1.1 Friday the Thirteenth
- USACO-Section1.1 Friday the Thirteenth【泰勒公式】
- USACO 1.1 Friday the Thirteenth
- USACO之Section1.1.3 Friday the Thirteenth
- USACO 1.1.3 Friday the Thirteenth
- USACO Friday the Thirteenth 解题日志
- usaco--Friday the Thirteenth
- USACO Section 1.1-3 Friday the Thirteenth
- USACO 1.1-Friday the Thirteenth
- usaco Friday the Thirteenth
- USACO1.1.3--Friday the Thirteenth
- 洛谷 [USACO1.1]黑色星期五Friday the Thirteenth
- USACO -Friday the Thirteenth
- USACO 1.1 Friday the Thirteenth