洛谷 1202 [USACO1.1] 黑色星期五 Friday the Thirteenth
2018-03-21 15:57
525 查看
题目
求从1900年1月1日到1900+n-1年12月31日x月13日星期一至星期日有多少天,记住:从周六开始输出。
分析
模拟,注意闰年代码
#include <cstdio> using namespace std; const int date[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int n,m=1899,ans=0,w[7]; int main(){ scanf("%d",&n); while (n--){ m++; for (int i=1;i<13;i++){ w[ans=(ans+6)%7]++;//从x月1日到x月13日到星期几 ans=(ans+date[i]-13+(i==2&&(m%4==0&&m%100!=0||m%400==0)))%7;//到月底(闰年)到星期几 } } for (int i=6;i<=12;i++) printf("%d ",w[i%7]); return 0; }
相关文章推荐
- [USACO1.1]黑色星期五Friday the Thirteenth-洛谷 1202
- 洛谷 [USACO1.1]黑色星期五Friday the Thirteenth
- luogu1202 [USACO1.1]黑色星期五Friday the Thirteenth
- luogu1202 [USACO1.1]黑色星期五Friday the Thirteenth
- luogu1202 [USACO1.1]黑色星期五Friday the Thirteenth
- 洛谷 P1202 [USACO1.1]黑色星期五Friday the Thirteenth
- 【模拟】洛谷 P1202 [USACO1.1]黑色星期五Friday the Thirteenth
- 【USACO1.1_3】★Friday the Thirteenth 黑色星期五
- Usaco 1.1.3 黑色星期五(Friday the Thirteenth)
- USACO 1.1 Friday the Thirteenth (friday)
- usaco/1.1 Friday the Thirteenth
- USACO Section 1.1 Friday the Thirteenth
- USACO section 1.1 Friday the Thirteenth
- USACO 1.1 Friday the Thirteenth
- USACO 1.1 Friday the Thirteenth
- USACO--1.1Friday the Thirteenth+简单模拟
- USACO-Section1.1 Friday the Thirteenth [日期]
- USACO1.1 Friday the Thirteenth 比较分析
- USACO 1.1 Friday the Thirteenth
- [USACO1.1]Friday the Thirteenth