输出y1到y2年之间的每一年的a月份的第b个周c。感觉像是一个恶心的模拟。更像一个很恶心的小学奥赛题。

题目:http://115.28.138.223/view.page?gpid=T25

考试的时候。我猜我是做不出来的。感觉这个代码的函数用的太机智了。某人智商堪忧丫。。。

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std; int run(int year) { // 判断是否是闰年。
if (year % == ) return ;
else if (year % != && year % == ) return ;
else return ;
} int days (int leap, int month) { // 判断这一年的1月到month月开始一共有多少天。这个函数好机智有木有。
switch (month) {
case : return ;
case : return ;
case : return leap ? : ;
case : return leap ? : ;
case : return leap ? : ;
case : return leap ? : ;
case : return leap ? : ;
case : return leap ? : ;
case : return leap ? : ;
case : return leap ? : ;
case : return leap ? : ;
case : return leap ? : ;
}
} int monthDays(int leap, int temp) { // 判断当年的temp月有多少天。
switch (temp) {
case :
case :
case :
case :
case :
case :
return ;
case :
case :
case :
case :
case :
return ;
case :
return leap ? : ;
}
} int main() {
int month, week, day, y1, y2;
while(cin >> month >> week >> day >> y1 >> y2) {
int leapCount = ;
for (int i=; i<y1; ++i) {
if (run(i) == ) leapCount++;
}
for (int i=y1; i<=y2; ++i) {
// 对于我这种小学数学没学好的人来说。。。下面的计算太难了。。
int totDay = (i-)* + leapCount + days(run(i), month); // 从1850年开始到当年的这个月开始一共有多少天。
int weekDay= totDay% + ; //当年的这个月开始时周几。
int weekCount = day < weekDay ? : ; //需要跨过几个周。如果day>weekDay。说明计数周又可以减少一个。基数是1。因为是第几周的周几。所以跨过week-1就好了。
int ans = -weekDay + (week - weekCount)* + day;
if (ans <= monthDays(run(i), month)) // 如果这一天在这个月存在的话。输出。
{
cout << i << '/';
if (month < ) cout << "";
cout << month << '/';
if (ans < ) cout << "";
cout << ans << endl;
}
else cout << "none\n";
if (run(i) == ) leapCount++; // 开始这里忘记了。!!!
}
}
return ;
}

CCF 2015-03-3 节日的更多相关文章

  1. iOS 学习笔记 六 (2015.03.28)常见错误

    2015.03.28 1. property's synthesized getter follows Cocoa naming convention for returning 'owned' ob ...

  2. Contest2071 - 湖南多校对抗赛(2015.03.28)

    Contest2071 - 湖南多校对抗赛(2015.03.28) 本次比赛试题由湖南大学ACM校队原创 http://acm.csu.edu.cn/OnlineJudge/contest.php?c ...

  3. CCF真题之节日

    201503-3 问题描述 有一类节日的日期并不是固定的,而是以“a月的第b个星期c”的形式定下来的,比如说母亲节就定为每年的五月的第二个星期日. 现在,给你a,b,c和y1, y2(1850 ≤ y ...

  4. https://blog.helong.info/blog/2015/03/13/jump_consistent_hash/

    转载请说明出处:http://blog.csdn.net/cywosp/article/details/23397179     一致性哈希算法在1997年由麻省理工学院提出的一种分布式哈希(DHT) ...

  5. iOS 学习笔记 七 (2015.03.29)code snippet操作

    1.code snippet 备份路径:~/Library/Developer/Xcode/UserData/CodeSnippets/

  6. iOS 学习笔记 五 (2015.03.17)使用storyBoard进行tableview的跳转

    方法一: 点击tableviewCell后,按住ctrl键拖拽至想要跳转的新的界面.这样跳转的结果是,点击tableview中的任何一行都会跳转到新的界面.可以通过控制cell的 属性 userInt ...

  7. iOS 学习笔记 三 (2015.03.05)

    服务和特征都是用UUID来唯一标识的,UUID的概念如果不清楚请自行google,国际蓝牙组织为一些很典型的设备(比如测量心跳和血压的设备)规定了标准的service UUID(特征的UUID比较多, ...

  8. Cheatsheet: 2015 03.01 ~ 03.31

    Web The Architecture of Algolia's Distributed Search Network No promises: asynchronous JavaScript wi ...

  9. Spring-demo1(初学者的尝试,2015.03.19)

    项目结构: 源代码如下: package com.bean; public interface Person { public void Speak(); } package com.bean; pu ...

  10. C# 日期格式转换 string类型 20150329 转换为 2015/03/29

    DateTime.ParseExact("20150329", "yyyyMMdd", System.Globalization.CultureInfo.Cur ...

随机推荐

  1. Python3基础 str endswith 是否以指定字符串结束

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  2. Git 同时与多个远程库互相同步

    情形:有两个git服务器,比如github,gitosc,有个项目同时在两个服务器上,要互相同步 其实命令还是比较简单的,比如一个现有的git项目,在github,gitosc中分别创建好对应的项目. ...

  3. 如何在一台主机上管理自己的多个git repository

    在使用git时,通常是直接ssh-keygen生成默认秘钥.然后将共钥添加到远程仓库,就可以访问了. 但是,当我们有多个repository时,这种方式就不适用了,因为一个秘钥只能关联一个远程仓库. ...

  4. echart折线图,柱状图,饼图设置颜色

    转载: 之前在做报表的时候用过echart 用完也就完了,而这次在用的时候已经忘了,所以这里简单记录一下,好记性不如烂笔头!!! 1.折线图修改颜色: xAxis: { type: 'category ...

  5. POJ 1625 Censored!(AC自动机+高精度+dp)

    http://poj.org/problem?id=1625 题意: 给出一些单词,求长度为m的串不包含这些单词的个数. 思路: 这道题和HDU 2243和POJ 2778是一样的,不同的是这道题不取 ...

  6. HDU 5834 Magic boy Bi Luo with his excited tree(树形dp)

    http://acm.hdu.edu.cn/showproblem.php?pid=5834 题意: 一棵树上每个节点有一个价值$Vi$,每个节点只能获得一次,每走一次一条边要花费$Ci$,问从各个节 ...

  7. UVa 11636 你好 世界!(贪心)

    https://vjudge.net/problem/UVA-11636 题意: 经过一次复制,一条语句会变成两条语句,再经过一次变成四条语句...求最少需要复制几次能使条数恰好为n? 思路: 贪心水 ...

  8. UVa 1411 Ants(分治)

    https://vjudge.net/problem/UVA-1411 题意:n只蚂蚁和n颗苹果树,一一配对并且不能交叉. 思路:这就是巨人与鬼的问题.用分治法就行了. #include<ios ...

  9. Mui --- 页面之间的传值

    A页面 mui.ajax('http://14.50.2.49:80/default/AppLogin?Prm=' + Prm, { data: {}, //dataType: 'json', typ ...

  10. linux——通信指令学习简单笔记

    一: 指令名称:write 指令所在路径:/usr/bin/write 执行权限:All User 语法:write <用户名> 功能描述:向另外一个用户发信息,以Ctrl+D作 为结束 ...