usaco Friday the Thirteenth
来源:互联网 发布:火狐javascript设置 编辑:程序博客网 时间:2024/06/09 01:08
找规律,1900的一月一日是星期last = 1,那么1月13日是星期((13 - 1)% 7 + last) = 6;last = 6;因为一月有31天,所以1月13离2月13是31天, 2月13日是星期 (31 % 7 + last) % 7 = 2; last = 2;以此类推。
/**LANG: C++PROG: fridayID: grttman1**/#include <iostream>#include <fstream>#include <string>#include<cstring>using namespace std;const int maxn = 400 + 5;const int s = 1900;int day[8];int month[13] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};int main(){ freopen("friday.in","r",stdin); freopen("friday.out","w",stdout); int n; while(scanf("%d", &n) == 1) { memset(day, 0, sizeof(day)); int last = 6; for(int i = 0; i < n; i++) { int year = s + i; if(year % 4 == 0 && year % 100 != 0 || (year % 400 == 0)) { month[1] = 29; } else month[1] = 28; for(int j = 1; j < 12; j++) { last = (month[j - 1] % 7 + last) % 7; day[last]++; } if(i != n - 1) { last = (month[11] % 7 + last) % 7; day[last]++; } } day[6]++; printf("%d %d %d %d %d %d %d\n", day[6], day[0], day[1], day[2], day[3], day[4], day[5]); } return 0;}
阅读全文
0 0
- 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
- USACO Friday the Thirteenth
- USACO Friday the Thirteenth
- USACO--Friday the Thirteenth
- usaco Friday the Thirteenth
- usaco Friday the Thirteenth
- usaco Friday the Thirteenth
- USACO 1.1-Friday the Thirteenth
- usaco 1.1:Friday the Thirteenth
- USACO 1.1 Friday the Thirteenth
- USACO之Friday the Thirteenth
- 【USACO】PROB Friday the Thirteenth
- Assertion "OSQCreate" failed at line 71 in ..\LWIP\arch\sys_arch.c错误解决方法
- lua语言学习笔记
- Android中 跳转到系统设置界面
- Dubbo架构设计详解
- jQuery特殊属性之val方法
- usaco Friday the Thirteenth
- Plugin with id 'com.android.application' not found. 解决
- 面试系列-冒泡排序
- jvm 系统调优,确定高CPU程序代码
- Android4.4修改状态栏颜色
- java读取excel指定的位置
- vsftpd不能显示文件目录的解决方法
- Jenkins远程部署 gitLab配置
- springboot