题目链接:http://acm.zzuli.edu.cn/problem.php?id=2600

  模拟,既然1900 01 01是周一,那就从这一天开始加,直到加到满足题目条件的区间里再去做判断

#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define mst(a) memset(a, 0, sizeof(a))
#define _test printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n")
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double eps = 1e-;
const int INF = 0x3f3f3f3f;
const ll ll_INF = 0x3f3f3f3f3f3f3f;
const int maxn = 1e4+;
const int ls[] = {, , , , , , , , , , , , };
bool isr(int y) { //判断闰年
return (y% && !(y%)) || !(y%);
}
bool ok(int sum, int w) { //判断是不是周w
return sum% + == w;
}
int main(void) {
int x, y, z, w;
while(~scanf("%d%d%d%d", &x, &y, &z, &w)) {
ll sum = z-;
int start = ;
while(start < x) { //计算x年1月z号到1900年1月1号的天数
sum += ( + isr(start));
++start;
}
int cnt = ;
while(start <= y) { //求解答案
for (int i = ; i<=; ++i) {
sum += ls[i-]; //加上上个月的天数
if (i == ) //如果要加上2月的天数, 判断要不要补1
sum += isr(start);
if ((i== && z > ls[]+isr(start)) || (i != && z > ls[i])) //如果该月的z号不存在,跳过, 不统计次数
continue;
cnt += ok(sum, w); //统计次数
}
sum += ls[]; //加上第十二月的天数
++start; //换到下一年
}
printf("%d\n", cnt);
}
return ;
}

最新文章

  1. JavaWeb_day05cookie_session_HttpSession
  2. 用css画实心三角形
  3. linux服务开机启动顺序
  4. Python基础:1.数据类型(列表)
  5. C# Winform 实现自定义半透明loading加载遮罩层
  6. GridView的初级使用
  7. 移动端Click300毫秒点击延迟的来龙去脉(转)
  8. webService常见问题
  9. 原生js选项卡
  10. Linux指令--chown
  11. SpringMVC之数据传递二
  12. user 不在 sudoers 文件中。此事将被报告。
  13. 用C# 模拟实现unity里的协程
  14. Matlab提供了两种除法运算:左除(\)和右除(/)
  15. Linux文件系统命令 cp
  16. ML(1)——机器学习简述
  17. Java-函数式编程(二)Lambda表达式
  18. 单表(SSM、SpringBoot、SpringCloud、Freemaker、BootStrap等)
  19. java基础学习总结——异常处理
  20. Simple2D-17(音乐播放器)嵌入 ImGui 库

热门文章

  1. 关于ios 11.X后微信wifi认证,无法打开微信,无法重定向到weixin:开头网址等问题的处理
  2. 解决 Ubuntu16.04 + opencv4.1 源码编译错误 Makefile:160: recipe for target &#39;all&#39; failed
  3. Python连载36-线程数量限制、Timer、可重入锁
  4. Worker Services的新项目模板
  5. .Net轻松处理亿级数据--ClickHouse数据操作
  6. Dapper - 一款轻量级对象关系映射(ORM)组件,DotNet 下
  7. 【UOJ#82】【UR #7】水题生成器(贪心)
  8. java的递归异常—一个异常可能由另一个异常触发
  9. 使用SolrJ客户端管理SolrCloud(Solr集群)
  10. 【JS】---5 JS通过事件隐藏显示元素