首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

USACO Section 1.1.3 [Friday the Thirteenth] Java例题

2012-11-06 
USACO Section 1.1.3 [Friday the Thirteenth] Java题解题意分析:已知1900年1月1日是周一(即1900年1月13日

USACO Section 1.1.3 [Friday the Thirteenth] Java题解
题意分析:
已知1900年1月1日是周一(即1900年1月13日是周六),求1900年1月1日开始,N年间每月13号这一天分别落在周一,周二……到周日的次数。

解题思路:
从1900年1月起枚举N年间的每一个月份:由该月13号为周几,算出下个月13号为周几,注意考虑闰年。

代码实现:
https://github.com/leonlu/USACOJavaSolution/blob/master/USACOSection1/src/friday.java

热点排行