首页 技术 正文
技术 2022年11月14日
0 收藏 482 点赞 3,431 浏览 1228 个字

hihocoder1148https://hihocoder.com/problemset/problem/1148

因为题目没有给范围,我本来是这么写的。

 for(int i = ; i <= ; i++){
if(i%==&&i%!=||i%==){
cnt++;
}
memo[i] = cnt;
}

然后RE了,事实证明长度还是很大的。

本题的关键在于利用计算闰年的方法巧妙地实现类似以上的计数。

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<iterator>
#include<queue>
#include<cctype>
#include<map>
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define IO ios::sync_with_stdio(false);cin.tie(0);
#define INF 0x3f3f3f3f
#define MAXN 100010
const int MOD=1e9+;
typedef long long ll;
using namespace std;
int n, d1, d2, yy1, y2;
char s1[], s2[];
map<string, int> mp;
int main()
{
cin >> n;
int kase=, cnt=;
mp["January"]=;mp["February"]=;mp["March"]=;
mp["April"]=;mp["May"]=;mp["June"]=;
mp["July"]=;mp["August"]=;mp["September"]=;
mp["October"]=;mp["November"]=;mp["December"]=;
for(int i = ; i < n; i++){
cnt=;
scanf("%s %d, %d", s1, &d1, &yy1);
scanf("%s %d, %d", s2, &d2, &y2);
if(yy1 != y2){
//容斥的感觉
int k1 = yy1/-yy1/+yy1/;
int k2 = (y2-)/-(y2-)/+(y2-)/;
cnt=k2-k1; if(yy1%==&&yy1%!=||yy1%==){
if(mp[s1] <= ){
cnt++;
}
}
if(y2%==&&y2%!=||y2%==){
if(mp[s2] > ||mp[s2]==&&d2==){
cnt++;
}
}
}
else{
if(yy1%==&&yy1%!=||yy1%==){
if((mp[s1] <= )&&(mp[s2]>||mp[s2]==&&d2==))
cnt++;
}
}
cout << "Case #" << ++kase << ": ";
cout << cnt << endl;
}
return ;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,989
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,504
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,348
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,131
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,765
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,842