UVA 1524 - Hot or Cold?

题目链接

题意:给一个一元n次方程,带入x表示时间,f(x)表示温度,如今要求[s, e]的平均温度

思路:平均温度就是 总温度/ (e - s),画出曲线,能够发现温度总和为[s,e]上区间与x轴围成的面积,那么利用f(x)的原函数就能求面积了

代码:

#include <cstdio>
#include <cstring>
#include <cmath> const int N = 105; int n;
double a[N], s, e; double F(double x) {
double ans = 0;
for (int i = 0; i <= n; i++)
ans += a[i] * pow(x, i + 1);
return ans;
} int main() {
int cas = 0;
while (~scanf("%d", &n) && n) {
for (int i = n; i >= 0; i--) {
scanf("%lf", &a[i]);
a[i] = a[i] / (i + 1);
}
scanf("%lf%lf", &s, &e);
printf("%.3lf\n", (F(e) - F(s)) / (e - s));
}
return 0;
}

UVA 1524 - Hot or Cold?(数学)的更多相关文章

  1. UVa 12230 - Crossing Rivers(数学期望)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  2. UVA&&POJ离散概率与数学期望入门练习[4]

    POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...

  3. UVA 113 Power of Cryptography (数学)

    Power of Cryptography  Background Current work in cryptography involves (among other things) large p ...

  4. UVa 11461 - Square Numbers【数学,暴力】

    题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  5. UVA 11582 Colossal Fibonacci Numbers(数学)

    Colossal Fibonacci Numbers 想先说下最近的状态吧,已经考完试了,这个暑假也应该是最后刷题的暑假了,打完今年acm就应该会退了,但是还什么都不会呢? +_+ 所以这个暑假,一定 ...

  6. UVa 11762 Race to 1 (数学期望 + 记忆化搜索)

    题意:给定一个整数 n ,然后你要把它变成 1,变换操作就是随机从小于等于 n 的素数中选一个p,如果这个数是 n 的约数,那么就可以变成 n/p,否则还是本身,问你把它变成 1 的数学期望是多少. ...

  7. UVa 11427 Expect the Expected (数学期望 + 概率DP)

    题意:某个人每天晚上都玩游戏,如果第一次就䊨了就高兴的去睡觉了,否则就继续直到赢的局数的比例严格大于 p,并且他每局获胜的概率也是 p,但是你最玩 n 局,但是如果比例一直超不过 p 的话,你将不高兴 ...

  8. UVA 12723 Dudu, the Possum --数学期望

    题意不说了,概率和期望值要分开处理. 方法1:可以先算出到达每层的概率,然后再乘以每层的期望,每层的期望是固定的. 方法二:也可以从后往前直接推期望.为什么从后往前呢?因为第i层的时候,它可以跳到的层 ...

  9. UVA 11481 - Arrange the Numbers 数学

    Consider this sequence {1, 2, 3, . . . , N}, as a initial sequence of first N natural numbers. You ca ...

随机推荐

  1. KMP算法解析

    介绍一种高效的KMP算法:代码可以直接运行 #include <iostream> #include <iomanip> using namespace std; void p ...

  2. Microsoft Jet 数据库引擎找不到对象'Sheet1$_'。请确定对象是否存在,并正确地写出它的名称和路径

    We have a CRM add-on for Importing Price Lists into CRM. For this tool, we expect the details to be ...

  3. HDU p1294 Rooted Trees Problem 解题报告

    http://www.cnblogs.com/keam37/p/3639294.html keam所有 转载请注明出处 Problem Description Give you two definit ...

  4. large-scale analysis of malware downloaders

    http://www.christian-rossow.de/publications/downloaders-dimva12.pdf

  5. ASP.NET路由

    ASP.NET 路由使您可以使用不必映射到网站中特定文件的 URL. 由于该 URL 不必映射到文件,因此可以使用对用户操作进行描述因而更易于被用户理解的 URL. ASP.NET MVC 框架和 A ...

  6. PendingIntent.getBroadcast第四个参数flags

    (1) android.app.PendingIntent.FLAG_UPDATE_CURRENT 如果PendingIntent已经存在,保留它并且只替换它的extra数据. (2) android ...

  7. Hibernate + Spring (quartz) 整合懒(延迟)加载问题

    开发项目的时候 在一个Job中执行了数据库操作, 用的是懒加载,但是如下错误 org.hibernate.LazyInitializationException: failed to lazily i ...

  8. datetime.datetime.today()生成时间转换成unixtime

    首先要将时间中秒后面的.及其以后的部分去掉,否则时间转换函数 currenttime=str((datetime.datetime.today())).split('.',2)[0] str((dat ...

  9. modelsim中的文件操作—— 大数据测试

    在modelsim中不可避免的需要进行文件操作,在窗口中查看代码的操作情况,下面是我自己M序列实验中的一段测试代码 integer i,j ,k,m; integer m_dataFILE , ind ...

  10. 纯JAVA驱动:sqlserver版本不同,驱动与连接也有所区别

    纯JAVA驱动:// 2005 版本:驱动:Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");连接:”jd ...