USACO 1.1.3 Friday the Thirteenth
来源:互联网 发布:c语言书籍推荐 知乎 编辑:程序博客网 时间:2024/05/22 21:58
比较简单,直接模拟,需要注意闰年的判断和对不同月份日期的处理。
代码如下:
/*ID: michael139LANG: CPROG: friday*/#include<stdio.h>#include<string.h>int is_leapYear(int y);int main () { FILE *fin = fopen ("friday.in", "r"); FILE *fout = fopen ("friday.out", "w"); int n,i,j,cur,count[7]; while (fscanf(fin,"%d",&n) != EOF) { memset(count,0,sizeof(count)); cur = 2;//Monday for (i=1900;i<=1900+n-1;i++) { for (j=1;j<=12;j++) { cur += 12; count[cur%7] ++ ; if (j==1 || j==3 || j==5 || j==7 || j==8 || j==10 || j==12) { cur += 19; } else if (j==4 || j==6 || j==9 || j==11) { cur += 18; } else { if (is_leapYear(i)) cur += 17; else cur += 16; } } } for (i=0;i<7;i++) { fprintf(fout,"%d",count[i]); if (i!=6) fprintf(fout," "); } fprintf(fout,"\n"); } return 0;}int is_leapYear(int y) { return (y%4==0) && (y%100!=0 || y%400==0);}
- USACO 1.1.3 Friday the Thirteenth (friday)
- USACO 1.1.3 Friday the Thirteenth
- USACO 1.1.3 Friday the Thirteenth
- [USACO 1.1.3] Friday the Thirteenth
- USACO 1.1.3 Friday the Thirteenth
- USACO 1.1.3 Friday the Thirteenth
- USACO 1.1.3 Friday the Thirteenth
- USACO 1.1.3 Friday the Thirteenth
- USACO Section 1.1.3 Friday the Thirteenth
- USACO 1.1.3 - Friday the Thirteenth(模拟)
- USACO 1.1-Friday the Thirteenth
- usaco 1.1:Friday the Thirteenth
- USACO 1.1 Friday the Thirteenth
- usaco/1.1 Friday the Thirteenth
- USACO 1.1 Friday the Thirteenth
- USACO 1.1 Friday the Thirteenth
- USACO 1.1 Friday the Thirteenth
- USACO 1.1-Friday the Thirteenth
- 数据库三范式
- CKEditor 在jsp中实现文件上传的完整例子
- 常用宏定义
- 硬件工程师如何定位,增值?
- 嵌入式Linux学前建议(初学者必读)
- USACO 1.1.3 Friday the Thirteenth
- 远程桌面
- 读取Assets目录下的文件信息(此处主要是读取Zip包和Apk的信息)
- [WP7]Silverlight: Creating a WriteableBitmap from a Uri Source
- 后缀数组(倍增)
- MFC阶段一
- JavaScript(一)
- Vega Prime与OSG的比较
- 为什么Flex屏蔽了“帧”的概念?