UVALive 2034 Hot or Cold?【数学】
来源:互联网 发布:淘宝权重怎么提升 编辑:程序博客网 时间:2024/06/03 07:50
Description
John Smith, who is a member of Academy of Cold Manager (ACM), is in charge of a large-scale cold store. For him, it's a troublesome job. Whenever the temperature in the cold store is too hot or too cold for a long time, the goods will be damaged. And poor Mr. Smith will have to compensate for the loss of the store.
Therefore, Mr. Smith has installed an automatic temperature control system in the store. The system may control the temperature according to the input polynomial and the start time. At each moment, it tries to adjust the temperature equal to the value of the polynomial function. But Mr. Smith still feels worried. Since he could not know the effect beforehand how the system will regulate. At such a worrisome moment, it's lucky for him to call to remembrance that you, an excellent programmer, are willing to offer a program to help him. Making use of this program, he may simply input the polynomial and the parameters of the start time and the end time, and then he will be aware of the average temperature during this period. Now he is relieved from such a bothersome job.
Input
The input file may contain several data sets. Each data set begins with a line containing an integer n(n < 100), which specifies the highest power of the polynomial. A value of 0 for the power indicates the end of input, and this data set should not be processed. In each data set, the following line contains n + 1 real numbers, which tell the coefficients of the polynomial. The sequence of those coefficients is arranged according to the power of items from high to low in the polynomial. If an item of the polynomial does not exist, the corresponding coefficient is 0. And then follows a line consists of 2 real numbers s and e(s < e), indicating the start time and the end time.
Output
For each data set, compute t, the average temperature of the input polynomial from the start time to the end time. Print your answer as a single real number accurate to 3 decimal places on a line by itself. You should not print any more white spaces or blank lines in the output.
Sample Input
2 1.0 0.0 0.0 0.0 1.0 0
Sample Output
0.333
给出一个n次多项式,这个n次多项式是温度关于时间的函数,现在给出起始时间和终止时间,求这段时间的平均的温度
对这个多项式求从初始到终止的积分值。最后除去总时间,即为所求...
#include<cstdio>#include<cstring>#include<cmath>using namespace std;int main(){int n;while(scanf("%d",&n),n){double p[105]={0};for(int i=n;i>=0;--i){scanf("%lf",&p[i]);}double bg,ed,x[105]={0},ans=0;scanf("%lf%lf",&bg,&ed);for(int i=n;i>=0;--i){x[i+1]=p[i]/(i+1);ans+=x[i+1]*pow(ed,i+1);ans-=x[i+1]*pow(bg,i+1);}printf("%.3lf\n",ans/(ed-bg));}return 0;}
- UVALive 2034 Hot or Cold?【数学】
- 【UVALive】2034 - Hot or Cold?(数论)
- UVA 1524 - Hot or Cold?(数学)
- UVa 1524 - Hot or Cold?
- 【UVa】[1524]Hot or Cold?
- uva 1524 - Hot or Cold?(积分)
- UVA 1524 - Hot or Cold? 【求积分】
- hot and cold observable
- COLD VS HOT OBSERVABLES
- Angular2:Cold vs Hot Observables
- UVALive 6918 And Or 数学二进制+枚举
- Algs4-1.4.34热还是冷-猜出秘密数(Hot or Cold guess a secret integer)
- RxJava----操作符:cold&hot Observable
- RxJava 驯服数据流之 hot & cold Observable
- RxJava 驯服数据流之 hot & cold Observable
- RxJava 驯服数据流之 hot & cold Observable
- GNU中attribute中的cold和hot
- 热备份、温备份、冷备份(Hot/Warm/Cold Backup)
- jdk1.6 完美卸载
- hdu5727 Necklace(枚举+匈牙利)
- 如何进行mysql的优化
- Java如何把String[]类型的记录插入到Mysql中
- CF 699D Fix a Tree 并查集
- UVALive 2034 Hot or Cold?【数学】
- iOS byte截取 socket解析
- Qt中文件读取的几种方式
- iOS工程准备工作
- 7.18-7.24学习小结
- 杭电 hdu 1062 Text Reverse
- Android学习笔记033之数据存储—SharedPreference
- powershell
- linux系统下多用户的操作