2015 编程之美 资格赛 第一题 hihocoder 区间闰年 2月29 数量 模拟题
2015-04-17 15:46
239 查看
#include <string.h> ->memset()的头文件
http://hihocoder.com/contest/msbop2015qual/problem/1
#include <iostream> #include <string> #include <stdio.h> #include <memory> #include <string.h> using namespace std; string m[]={"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November" , "December"}; class year2 { public : int year; string mouth; int day; int i_mouth; int special; void tran_mouth() { for(int i=0;i<12;i++) if(mouth==m[i]) i_mouth=i+1; }; void cal() { special=year/4-year/100+year/400; }; bool is_special() { if(year%400==0||(year%4==0&&year%100!=0)) { return true; } return false; }; bool before_include_special() { if(i_mouth<2||(i_mouth==2&&day<=29)) return true; else return false; }; bool before_special() { if(i_mouth<2||(i_mouth==2&&day<29)) return true; else return false; }; }; int main() { int T; int Case=0; cin>>T; while(T--) { char t; Case++; year2 start; year2 end; cin>>start.mouth; cin>>start.day; cin>>t; cin>>start.year; cin>>end.mouth; cin>> end.day; cin>> t; cin>> end.year; start.tran_mouth(); start.cal(); end.tran_mouth(); end.cal(); int ans= end.special- start.special; if(start.is_special()&&start.before_include_special()) { ans+=1; } if(end.is_special()&&end.before_special()) { ans-=1; } cout<<"Case #"<<Case<<": "<<ans<<endl; } }
相关文章推荐
- `2015 编程之美 资格赛 第一题 hihocoder 区间闰年 2月29 数量 模拟题
- 2015编程之美 资格赛 B题 区间dp
- hihocoder 2015编程之美 资格赛 hihocoder 第三题 基站选址
- 【简单数学&DP】闰年计数&回文串计数 _Hihocoder战场 @ 编程之美2015资格赛
- 编程之美2015资格赛 题目2 : 回文字符序列 [ 区间dp ]
- 回文子序列数 编程之美 hihocoder 资格赛 第二题 2015年
- 2015编程之美 回文字符序列(区间Dp)
- 2015编程之美 该死的第一题
- 2015编程之美资格赛第一题
- hihocoder 微软编程之美2015 初赛 第一场 (树算法 + 暴力思想 + 搜索思想)
- 编程之美2015 资格赛 hihocoder 题目2: 回文字符序列
- ACM学习历程—BestCoder 2015百度之星资格赛1006 单调区间(组合数学)
- hihocoder 微软编程之美2015 初赛 第二场(暴力+字典序+图论+思维算法)
- hihoCoder 1156 彩色的树 编程之美2015初赛第一场
- 百度之星2015资格赛1003 IP聚合 模拟题
- bestCoder 2015 百度之星程序设计大赛 资格赛 1006单调区间
- 2015百度之星资格赛1006_单调区间
- hihoCoder 1159 扑克牌 编程之美2015初赛第二场
- HihoCoder1672 : 区间问题([Offer收割]编程练习赛41)(贪心)
- HihoCoder1649 : 漏写的数字([Offer收割]编程练习赛38)(模拟题)