NC207099. YetAnotherInfectiousVirus
描述
Nowadays, there is a widely spreading infectious pandemic disease named Coronavirus, which greatly influences all the aspects of our daily life.
(actually it’s 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 .输入描述
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; }