You are estimating the threat level of quarantined zones that have been abandoned to the infection.

One of the key variables in determining a zone’s threat level is the EIT (Effective Infection Time). This

information is essential for planning strike dates to reclaim quarantined zones. The EIT is calculated

according to the following rules:

• The EIT is the result of a function of two dates: The infection date and the strike date.

• All years are in A.Z. (After Zombie).

• Every month counts for a fraction of an EIT after its last day has passed. This means the month

of the strike date does not count for EIT.

• The first calendar year of the infection is calculated as 1/2 EIT.

◦ If the end of the year is not reached, each month only counts for a fraction of the 1/2 EIT. If

a zone was infected in January of the first year, then the 1/2 EIT is spread across 12 months

((1/2)/12 = ∼ 0.0417 EIT per month). If a zone was infected in March of the first year,

then the 1/2 EIT is spread across 10 months ((1/2)/10 = 0.0500 EIT per month).

◦ If the end of the year is reached, the year counts as a full 1/2 EIT, regardless of the infection

month. In other words, a zone infected in February of 15 A.Z. counts as only 1/2 (one-half)

EIT after December 15 A.Z. A zone infected in December of the same year will also count

as 1/2 EIT.

• All following years are calculated as 1 EIT. Each calendar month, beginning with January, counts

for 1/12 EIT (∼ 0.0833 EIT).

• Every zone infected on the same month will have the same EIT for any given strike date. Therefore

only the month and year are given.

The number and order of months in a calendar year remains the same as the modern

Gregorian calendar.

Input

The first line will be an integer N, where 1 ≤ N ≤ 50 giving the number of zones. For each zone, a

pair of lines of will be provided:

• The first line contains the infection date. The second contains the strike date.

• The first integer of a date represents the month, M (1 ≤ M ≤ 12), and the second integer

represents the year, Y (0000 ≤ Y ≤ 0030). The year will always have 4 digits.

• The strike date will never precede the infection date.

Output

Output the EIT for each zone on its own line. The EIT must be rounded to the fourth digit after the

decimal point. The ones-digit must always be printed even if it is a zero.

Sample Input

2

2 0009

11 0012

3 0010

10 0010

Sample Output

3.3333

0.3500

水题一个。题意真心难懂,读了不下1个小时。

题意:考虑第一年,若第一年过完了按0.5算。没过完就按0.5/x*y算,随后的每年的每月按1.0/12算。

计算出有多少月就能够了。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<limits.h>
typedef long long LL;
using namespace std;
double m1,y1;
double m2,y2;
int main()
{
int t;
cin>>t;
while(t--)
{
double ans;
cin>>m1>>y1>>m2>>y2;
if(y1==y2)
ans=0.5/(12-m1+1)*(m2-m1);
else
ans=(y2-y1-1)+1.0/12*(m2-1)+0.5;
printf("%.4lf\n",ans);
}
return 0;
}

UVA 6475 Effective Infection Time的更多相关文章

  1. Effective前端2:优化html标签

    div { float: left; } .keyboard > div + div { margin-left: 8px; } --> div{display:table-cell;ve ...

  2. Effective java笔记(二),所有对象的通用方法

    Object类的所有非final方法(equals.hashCode.toString.clone.finalize)都要遵守通用约定(general contract),否则其它依赖于这些约定的类( ...

  3. 《Effective java》-----读书笔记

    2015年进步很小,看的书也不是很多,感觉自己都要废了,2016是沉淀的一年,在这一年中要不断学习.看书,努力提升自己!预计在2016年要看12本书,主要涉及java基础.Spring研究.java并 ...

  4. 《Effective Java》学习笔记——积累和激励

    从一个实际案例说起 国庆长假前一个礼拜,老大给我分配了这么一个bug,就是打印出来的报表数量为整数的,有的带小数位,有的不带,毫无规律. 根据短短的两个多月的工作经验以及猜测,最终把范围缩小到以下这段 ...

  5. Effective前端5:减少前端代码耦合

    什么是代码耦合?代码耦合的表现是改了一点毛发而牵动了全身,或者是想要改点东西,需要在一堆代码里面找半天.由于前端需要组织js/css/html,耦合的问题可能会更加明显,下面按照耦合的情况分别说明: ...

  6. Effective前端4:尽可能地使用伪元素

    伪元素是一个好东西,但是很多人都没怎么用,因为他们觉得伪元素太诡异了.其实使用伪元素有很多好处,最大的好处是它可以简化页面的html标签,同时用起来也很方便,善于使用伪元素可以让你的页面更加地简洁优雅 ...

  7. Effective前端3:用CSS画一个三角形

    p { text-indent: 2em } .triangle-container p { text-indent: 0 } img { margin: 15px 0 } 三角形的场景很常见,打开一 ...

  8. Effective前端1:能使用html/css解决的问题就不要使用JS

    div{display:table-cell;vertical-align:middle}#crayon-theme-info .content *{float:left}#crayon-theme- ...

  9. Effective Java笔记一 创建和销毁对象

    Effective Java笔记一 创建和销毁对象 第1条 考虑用静态工厂方法代替构造器 第2条 遇到多个构造器参数时要考虑用构建器 第3条 用私有构造器或者枚举类型强化Singleton属性 第4条 ...

随机推荐

  1. go语言方法实例

    方便和函数的区别: 方法能给用户定义的类型添加新的行为.方法实际上也是函数,只是在声明时,在关键字func 和方法名之间增加了一个参数. package main import ( "fmt ...

  2. [转]python dubbo接口测试

    转自:https://www.cnblogs.com/chunyanxu/p/8732734.html 会吐泡泡的鱼 博客园 首页 新闻 新随笔 联系 管理 订阅 随笔- 57  文章- 0  评论- ...

  3. 路由网关zuul(七)

    一.定义 Zuul包含了请求的路由和过滤的2个主要的功能: 其中路由功能负责将外部请求转发到具体的微服务实例上,是实现外部访问统一入口的基础而过滤器功能则负责对请求处理过程进行干预,是实现请求校验,服 ...

  4. 卡特兰数 3134 Circle

    3134 Circle  时间限制: 1 s  空间限制: 32000 KB  题目等级 : 黄金 Gold 题解       题目描述 Description 在一个圆上,有2*K个不同的结点,我们 ...

  5. Linux命令之kill

    kill [-s signal | -p] [ --] pid… kill –l [signal] 终止指定进程.命令kill将指定的信号发送到指定的进程或进程组.如果没有指定信号,则发送SIGTER ...

  6. 【二维莫队】【二维分块】bzoj2639 矩形计算

    <法一>二维莫队,对n和m分别分块后,对块从上到下从左到右依次编号,询问以左上角所在块编号为第一关键字,以右下角标号为第二关键字排序,转移时非常厉害. O(q*n*sqrt(n)). #i ...

  7. 【博弈论】【SG函数】poj2311 Cutting Game

    由于异或运算满足结合律,我们把当前状态的SG函数定义为 它所能切割成的所有纸片对的两两异或和之外的最小非负整数. #include<cstdio> #include<set> ...

  8. TabHost

    (一) 知识点:id使用系统自带 1.效果图: 2.布局 activity_main.xml <?xml version="1.0" encoding="utf-8 ...

  9. Ubuntu 14 下,命令行终端显示短路径

    Ubuntu的终端命令行默认是长路径,即把路径深度全部显示出来,操作起来不是很方便,下面介绍命令行显示短路径的操作: $ vi ~/.bashrc 找到PS1=   的行,将\w(小写)改成\W(大写 ...

  10. SSL和TSL的区别【转】

    SSL由从前的网景公司开发有1,2,3三个版本,但现在只使用版本3 TLS是SSL的标准化后的产物 有1.0 1.1 1.2三个版本 默认使用1.0 TLS1.0和SSL3.0几乎没有区别 事实上我们 ...