codeforces 304 B. Calendar
来源:互联网 发布:宝丽来效果软件 编辑:程序博客网 时间:2024/04/28 07:46
题目链接
就是给你两个日期,让你求两个日期之间差多少天。
我先算出两个日期分别是公元多少天,然后相减得到结果。
//cf 304B//2013-06-05-18.38#include <stdio.h>#include <stdlib.h>int y, m, d;int a[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};int loop(int y){ if (y%4 == 0 && y%100 != 0 || y%400 == 0) return 1; return 0;}int count(){ int sum = 0; for (int i = 1; i < y; i++) { sum += 365; if (loop(i)) sum++; } for (int i = 1; i < m; i++) sum += a[i]; if (loop(y) && m > 2) sum += 1; sum += d; return sum;}int main(){ scanf("%d:%d:%d", &y, &m, &d); int ans1 = count(); scanf("%d:%d:%d", &y, &m, &d); int ans2 = count(); printf("%d\n", abs(ans2 - ans1)); return 0;}
- codeforces 304 B. Calendar
- codeforces 304B. Calendar (日期相减)
- Codeforces Round #183 (Div. 2) B. Calendar
- Codeforces Round #183 (Div. 2) B. Calendar 天数差
- Problem G B. Calendar Codeforces Round #183 (Div. 2)
- codeforces Calendar
- B. Calendar
- CF 304B(Calendar-一段时间的日期)
- Educational Codeforces Round 13 A.Johny Likes Numbers && B. The Same Calendar
- B. Vasya's Calendar
- codeforces B
- codeforces B
- codeforces B
- codeforces B
- Codeforces-B.Soldier and Badges - Codeforces Round #304 (Div. 2)
- Codeforces Round #304 (Div. 2) B
- 【63.63%】【codeforces 724A】Checking the Calendar
- [codeforces]A. Checking the Calendar 水题
- 【黑马程序员】JSP页面的五种跳转方法
- 【黑马程序员】有关内部类和封装类的总结
- 大数copy相关的函数
- Windows 下安装并配置 SVN 服务器全过程
- Cocos2d-x Win32键盘模拟触摸事件
- codeforces 304 B. Calendar
- 黑马程序员java学习—泛型
- http get post限制
- Android中的Touch事件处理流程
- servlet下载片段
- 二叉树的生成与三种遍历
- 设计模式 - 单例模式、享元模式
- POJ 2773 Happy 2006 二分 and 容斥原理 or 欧拉函数
- 快速整合TOMCAT6.0.14+IIS6.0 不需要写什么注册表