# Snapshot 6475 Effective Infection Time, 6475 infection

Source: Internet
Author: User

Snapshot 6475 Effective Infection Time, 6475 infection
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 (valid tive 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.
Else 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 every SS 12 months
(1/2)/12 = week 0.0417 EIT per month). If a zone was infected in March of the first year,
Then the 1/2 EIT is spread every SS 10 months (1/2)/10 = 0.0500 EIT per month ).
Else 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. count 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 (cost 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,
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

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

The question is really hard to understand. I have been reading it for less than an hour.

Question: In the first year, if the first year is over 0.5, then 0.5/x * y is used. In the next year, 1.0/12 is used. Calculate the number of months.

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

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.