列表

详情


NC207099. YetAnotherInfectiousVirus

描述

Nowadays, there is a widely spreading infectious pandemic disease named Coronavirus, which greatly influences all the aspects of our daily life.

From the latest official statistics, the number of people who diagnosed with 2019-nCoV reaches 3834512 worldwide, while the number of deaths caused by 2019-nCoV attains to 267887 until May 8th, 2020. Here shows the picture of it:

In recent years, with the development of the technology and the eruption of some kinds of infectious diseases such as HIV, SARS, H1N1, H5N7 for research. Scientists have already established some Infectious Disease Models within accuracy. One of these models that seems quite suitable to the changing trend of Coronavirus is called SIS model.
The SIS model assumes that:
1. The population at time t is divided into susceptible people (proportion of the total number of people s(t)) and infected people (proportion of the total number of people i(t)).
2. The average number of effective contacts per patient per day is a constant , called the daily contact rate. When a healthy person 

(actually its the susceptible person) contacts a patient, the healthy person always becomes infected.

3. The proportion of patients who are cured every day to the total number of patients is , called the daily cure rate. Obviously, is the incubation period (average period of infection) of this infectious disease. So the relationship of all the constants and variables satisfy that .
4. Then the differential equation model is established as:

After solving the differential equation, here shows the result of it:

It's considered that different regions adopt different measures in order to fight against Coronavirus, as well as the type of Coronavirus in different regions are not always the same. So that the rate of average number of effective contacts and proportion of cured patients are usually differ.
Now given the total population of different regions, maybe a city, a country or a continent, the number of infected people initially, along with two constants and which described above. Please use the SIS model to predict the number of infected people after t days (no more than 2 years).
Please note that the total population of different regions will not change during t days.

输入描述

There are multiple test cases. The first line of the input contains an integer T (1 ≤ T ≤ 1000), indicating the number of test cases. For each test case:
Each line contains three integers n, m, t and two float numbers and (1 ≤ n ≤ 2×, 0 ≤ m ≤ n, 0 ≤ t ≤ 730, 0 ≤ , ≤ 1), indicating the total population of different regions, the number of initial infected people, the period of time, the rate of average number of effective contacts and the percentage of cured patients.

输出描述

For each test case, you should output the result of the infected people that after t days. 
Because the result may be a float number, just round the result into an integer.

示例1

输入:

3
100 10 30 0.50 0.50
100 10 30 0.40 0.60
100 10 30 0.60 0.40

输出:

4
0
33

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

C++11(clang++ 3.9) 解法, 执行用时: 6ms, 内存消耗: 492K, 提交时间: 2020-06-06 15:00:40

#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
#define eps 1e-6
int main(){
	int i,k,m,n,t;
	double a,b,ans,cur,res;
	while(scanf("%d",&k)!=EOF){
		while(k--){
			scanf("%d%d%d%lf%lf",&n,&m,&t,&a,&b);
			cur=(double)m/n;
			if(m==0) printf("0\n");
			else{
				if(abs(a-b)<eps){
					res=1.0/(a*t+1.0/cur);
				}
				else{
					res=1.0/(a/(a-b)+(1.0/cur-a/(a-b))*exp(-1.0*t*(a-b)));
				}
				ans=(double)n*res;
				printf("%.0lf\n",ans);
			}
		}
	}
	return 0;
} 

C++14(g++5.4) 解法, 执行用时: 8ms, 内存消耗: 404K, 提交时间: 2020-07-16 09:59:19

#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;cin>>t;
    while(t--){
        double n,m,t,v,u;
        cin>>n>>m>>t>>v>>u;
        double eps=exp(1);
        double ans;
        if(v==u)ans=v*t+n/m;
        else ans=v/(v-u)+(n/m-v/(v-u))*pow(eps,(u-v)*t);
        printf("%.0lf\n",n/ans);
    }
    return 0;
}

上一题