六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 29|回复: 0

【水题】USACO Friday the Thirteenth

[复制链接]

升级  68.4%

272

主题

272

主题

272

主题

进士

Rank: 4

积分
842
 楼主| 发表于 2013-1-26 13:31:41 | 显示全部楼层 |阅读模式
进入USACO要注册才可看题: http://train.usaco.org/usacogate

题目:【翻译版、是别处的网站】http://www.wzoi.org/usaco/13%5C303.asp

SAMPLE INPUT (file friday.in)
20
SAMPLE OUTPUT (file friday.out)
36 33 34 33 35 35 34



历法中的水题,不多说……

/*ID: 1006100071PROG: fridayLANG: C++*/#include <iostream>#include <fstream>#include <algorithm>#include <string>#include <set>//#include <map>#include <queue>#include <utility>#include <iomanip>#include <stack>#include <list>#include <vector>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <ctype.h>using namespace std;int year[405];    //year表示前i年有多少天int month[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};inline bool isleap (int y){if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0)return true;return false;}inline int days (int y, int m){int j, day = year[y];for (j = 1; j < m; j++){if (j == 2 && !isleap (1900+y))day += 28;else day += month[j];}day += 13;return day;}int main(){/*freopen ("friday.in", "r", stdin);freopen ("friday.out", "w", stdout);*/int i, j, n, ans[10] = {0};for (i = 1; i <= 405; i++){if (isleap (1900+i-1))year = year[i-1] + 366;else year = year[i-1] + 365;}scanf ("%d", &n);for (i = 0; i < n; i++){for (j = 1; j < 13; j++)ans[days(i, j)%7]++;}printf ("%d %d", ans[6], ans[0]);for (i = 1; i < 6; i++)printf (" %d", ans);printf ("\n");}
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表