lightoj 1414
来源:互联网 发布:入门java看什么书 编辑:程序博客网 时间:2024/06/03 20:07
lightoj 1414
题目:February 29
It is 2012, and it’s a leap year. So there is a “February 29” in this year, which is called leap day. Interesting thing is the infant who will born in this February 29, will get his/her birthday again in 2016, which is another leap year. So February 29 only exists in leap years. Does leap year comes in every 4 years? Years that are divisible by 4 are leap years, but years that are divisible by 100 are not leap years, unless they are divisible by 400 in which case they are leap years.
In this problem, you will be given two different date. You have to find the number of leap days in between them.
解题思路:
- 怎么判断一个年份是闰年:(year % 4 == 0 && year % 100 != 0) || (year % 400)。
- 在计算年份之间有几个闰年是怎样避免计算重复:容斥定理, year / 4 - year / 100 + year / 400
- 怎么处理两个端点:当端点年份为闰年时,小的年份如果小于润天, 结果+1,大的年份如果小于润天,结果-1.
阅读全文
0 0
- lightoj 1414
- Lightoj 1414 - February 29
- lightoj 1414 February 29
- 【Lightoj 1414 - February 29 】
- lightoj 1414 - February 29
- LightOJ
- LightOJ
- LightOJ
- LightOJ
- LightOJ
- [LightOJ
- LightOJ
- LightOJ
- LightOJ
- LightOJ
- LightOJ
- LightOJ
- LightOJ
- Spring详解
- 2017北京云栖大会拉开帷幕,Clouder Lab动手实验室受开发者欢迎
- myeclipse控制台显示中文乱码问题
- 各种移动设备的媒体查询
- 安装Win10+Fedora27双系统导致Windows引导出现BCD崩溃怎么办?
- lightoj 1414
- Protégé入门
- 图像的能量
- 线程池
- angular的 单项删除 和 点击查询 正序 倒序 按照年龄 排序
- 使用Glide替换Picasso经验小结
- springMVC后台dao层增加数据后获取增加对象的id
- 详解Android 进程间通信的几种实现方式
- 11.网络编程(notebook)