USACO1.1.3 Friday the Thirteenth (friday)
来源:互联网 发布:java 获取绝对路径 编辑:程序博客网 时间:2024/05/18 01:56
1900年1月13号是星期六。然后每次加上这个月的天数再模7就行了。
注意判断闰年。
/*ID:shijiey1PROG:fridayLANG:C++*/#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int n;int cnt[8];int mon[15] = {0, 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};void getFib(int year) {bool flag = false;if (year % 100) {if (!(year % 4)) flag = true;} else {if (!(year % 400)) flag = true;}if (flag) mon[2] = 29;else mon[2] = 28;}int main() {freopen("friday.in", "r", stdin);freopen("friday.out", "w", stdout);scanf("%d", &n);int date = 6;for (int i = 0; i < n; i++) {int year = i + 1900;getFib(year);for (int month = 1; month <= 12; month++) {cnt[date]++;date = (date + mon[month]) % 7;}}for (int i = 6; i < 13; i++) {if (i != 6) printf(" ");printf("%d", cnt[i % 7]);}printf("\n");return 0;}
0 0
- USACO1.1.3 Friday the Thirteenth (friday)
- USACO1.1.3 Friday the Thirteenth (friday)
- USACO1.1.3[Friday The Thirteenth]
- USACO1.1.3 Friday the Thirteenth
- USACO1.1.3 - Friday the Thirteenth
- USACO1.1.3 Friday the Thirteenth
- usaco1.1.3 Friday the Thirteenth黑色星期五
- USACO1.1.3 Friday the Thirteenth(黑色星期五)
- [USACO1.1]Friday the Thirteenth
- USACO1.1.3 Friday the Thirteenth 13日星期五
- USACO1.1 Friday the Thirteenth 比较分析
- luogu1202 [USACO1.1]黑色星期五Friday the Thirteenth
- 洛谷 [USACO1.1]黑色星期五Friday the Thirteenth
- 【USACO1.1_3】★Friday the Thirteenth 黑色星期五
- 洛谷 P1202 [USACO1.1]黑色星期五Friday the Thirteenth
- [USACO1.1]黑色星期五Friday the Thirteenth-洛谷 1202
- 【模拟】洛谷 P1202 [USACO1.1]黑色星期五Friday the Thirteenth
- Friday the Thirteenth
- stable_matching算法的java实现.
- 为什么要使用ngnix
- USACO1.1.1 Your Ride Is Here (ride)
- Ubuntu安装git
- USACO1.1.2 Greedy Gift Givers (gift1)
- USACO1.1.3 Friday the Thirteenth (friday)
- USACO1.1.4 Broken Necklace (beads)
- USACO1.2.1 Milking Cows (milk2)
- USACO1.2.2 Transformations (transform)
- USACO1.2.3 Name That Number (namenum)
- USACO1.2.4 Palindromic Squares (palsquare)
- USACO1.2.5 Dual Palindromes (dualpal)
- C指针编程之道 ---第六次笔记
- 下一个土豪金就是你——2014俄罗斯移动游戏市场概况