USACO 1.1.3 Friday the Thirteenth
2013-07-21 23:04
357 查看
USACO 1.1.3 Friday the Thirteenth
http://cerberus.delos.com:791/usacoprob2?a=owpOMMkldPW&S=friday
题意:模拟。给定一个年数范围,计算在这些年中周一到周日为某个月13号的次数。
……不说了,早知道去做没做完的字符串题了。
代码+细节:
http://cerberus.delos.com:791/usacoprob2?a=owpOMMkldPW&S=friday
题意:模拟。给定一个年数范围,计算在这些年中周一到周日为某个月13号的次数。
……不说了,早知道去做没做完的字符串题了。
代码+细节:
#include<stdio.h> /* ID: 15257142 LANG: C TASK: friday */ int main(){ int num,i,a[20],b,n,j,c; FILE *fin = fopen ("friday.in", "r"); FILE *fout = fopen ("friday.out", "w"); fscanf(fin,"%d",&num); for(i = 0;i<=6;i++) a[i] = 0; b = 0; for(i = 1900;i<=1900+num-1;i++){ c = 1; b = b+13; n = b%7; if(n==0) n = 7; a[n-1]++; b = b+18; c = 2; b = b+13; n = b%7; if(n==0) n = 7; a[n-1]++; if((i%4==0&&i%100!=0)||(i%400==0)) b = b+16; /*闰年二月29天,普通为28天。这也能混。*/ else b = b+15; c = 3; b = b+13; n = b%7; if(n==0) n = 7; a[n-1]++; b = b+18; c = 4; b = b+13; n = b%7; /*可以整除,正好是周日的情况。*/ if(n==0) n = 7; a[n-1]++; b = b+17; c =5; b = b+13; n = b%7; if(n==0) n = 7; a[n-1]++; b = b+18; c = 6; b = b+13; n = b%7; if(n==0) n = 7; a[n-1]++; b = b+17; c = 7; b = b+13; n = b%7; if(n==0) n = 7; a[n-1]++; b = b+18; c = 8; b = b+13; n = b%7; if(n==0) n = 7; a[n-1]++; b = b+18; c = 9; b = b+13; n = b%7; if(n==0) n = 7; a[n-1]++; b = b+17; c = 10; b = b+13; n = b%7; if(n==0) n = 7; a[n-1]++; b = b+18; c = 11; b = b+13; n = b%7; if(n==0) n = 7; a[n-1]++; b = b+17; c = 12; b = b+13; n = b%7; if(n==0) n = 7; a[n-1]++; b = b+18; } fprintf(fout,"%d %d ",a[5],a[6]); for(i = 0;i<=4;i++){ fprintf(fout,"%d",a[i]); if(i!=4) fprintf(fout," "); } fprintf(fout,"\n"); return 0; }
相关文章推荐
- USACO 1.1.3 Friday the Thirteenth
- USACO1.1.3 Friday the Thirteenth
- usaco1.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
- USACO1.1.3--Friday the Thirteenth
- [USACO 1.1.3] Friday the Thirteenth
- USACO 1.1.3 - Friday the Thirteenth(模拟)
- USACO之Section1.1.3 Friday the Thirteenth
- USACO1.1.3 Friday the Thirteenth 13日星期五
- USACO1.1.3 Friday the Thirteenth(黑色星期五)
- USACO 1.1.3 Friday the Thirteenth
- USACO1.1.3 Friday the Thirteenth
- USACO1.1.3 Friday the Thirteenth (friday)
- Usaco 1.1.3 黑色星期五(Friday the Thirteenth)
- USACO1.1.3 Friday the Thirteenth (friday)
- USACO 1.1.3 Friday the Thirteenth (friday)
- USACO 1.1.3 Friday the Thirteenth
- USACO1.1.3 - Friday the Thirteenth