博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVA 6475 Effective Infection Time
阅读量:6808 次
发布时间:2019-06-26

本文共 2939 字,大约阅读时间需要 9 分钟。

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
#include
#include
#include
#include
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;}

转载地址:http://yptwl.baihongyu.com/

你可能感兴趣的文章
开发者的实用 Vim 插件(二)
查看>>
springcloud(四):熔断器Hystrix
查看>>
数据驱动型文化是大数据成功的关键
查看>>
《Python机器学习——预测分析核心算法》——2.3 对“岩石vs.水雷”数据集属性的可视化展示...
查看>>
机器学习初学者入门实践:怎样轻松创造高精度分类网络
查看>>
Ruby Tip:定义索引操作符
查看>>
优云automation实践技巧:简单4步完成自动化构建与发布
查看>>
【Android 】【Monkey Demons】 针对性的进行稳定性测试
查看>>
基于MongoDB与NodeJS构建物联网系统
查看>>
从云效1.0到2.0的升级,看技术如何驱动企业提效
查看>>
Struts2升级版本至2.5.10,高危漏洞又来了
查看>>
OpenCV 使用 FLANN 库实现特征匹配
查看>>
SOA webservice
查看>>
学习shell的第三天
查看>>
用Dart搭建HTTP服务器(2)
查看>>
Mysql + keepalived 实现双主热备读写分离
查看>>
kvm虚拟化学习笔记(十七)之KVM到KVM之v2v迁移
查看>>
zephir-(1)开篇介绍
查看>>
使用邮件客户端整合日常信息
查看>>
地址转换函数
查看>>