题目链接:HDU 1724 Problem Description Math is important!! Many students failed in 2+2's mathematical test, so let's AC this problem to mourn for our lost youth.. Look this sample picture: A ellipses in the plane and center in point O. the L,R lines will…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1724 函数都给出来了,可以用辛普森积分: 一开始 eps = 1e-8 TLE了,答案只要三位小数,那么 eps = 1e-5 即可: 这次用了比较标准的写法^_^ 代码如下: #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; typ…
OJ 题解传送门 //Achen #include<algorithm> #include<iostream> #include<cstring> #include<cstdlib> #include<cstdio> #include<cmath> int T; double a,b,l,r; using namespace std; double f(double x) { return b*sqrt(1.0-(x*x)/(a*a)…
simpson公式是用于积分求解的比较简单的方法(有模板都简单…… 下面是simpson公式(很明显 这个公式的证明我并不会…… (盗图…… 因为一段函数基本不可能很规则 所以我们要用自适应积分的方法 找了一道很水的积分题试试模板…… 关于simpson要*15 网上有很具体的证明过程…… (细节移步至:http://www2.math.umd.edu/~mariakc/teaching/adaptive.pdf #include<cstdio> #include<iostream>…
题目链接 题意:给出椭圆方程中的a和b,再给出l.r,求l到r的积分的二倍. 输出时要求精度控制为保留到小数点后3位,如下代码中,eps设为1e-9 1e-8时均TLE,1e-4可以AC,1e-3会WA 代码: #include<bits/stdc++.h> using namespace std; typedef long long LL; ; int n; double a,b,l,r; double F(double x) { -x*x/a/a); } double simpson(do…
题目链接 题意 给出一个椭圆,问一个[l, r] 区间(蓝色区域)的面积是多少. 思路 自适应辛普森积分 具体一些分析如上. 很方便,套上公式就可以用了. 注意 eps 的取值影响了跑的时间,因为决定了递归的深度. #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> pii; const int INF = 0x3f3f3f3f; const int N…
/* hdu 1724 Ellipse simpson积分 求椭圆的部分面积 simpson积分法 http://zh.wikipedia.org/zh-tw/%E8%BE%9B%E6%99%AE%E6%A3%AE%E7%A7%AF%E5%88%86%E6%B3%95 */ #include<stdio.h> #include<math.h> const double eps=1e-8; inline double jue(double a) { return a>0?a:-…
Ellipse Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2502    Accepted Submission(s): 1126 Problem Description Math is important!! Many students failed in 2+2's mathematical test, so let's AC…
Ellipse Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1977    Accepted Submission(s): 832 Problem Description Math is important!! Many students failed in 2+2’s mathematical test, so let's AC t…
Problem Description Math is important!! Many students failed in 2+2’s mathematical test, so let's AC this problem to mourn for our lost youth..Look this sample picture: A ellipses in the plane and center in point O. the L,R lines will be vertical thr…
1502: [NOI2005]月下柠檬树 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1387  Solved: 739[Submit][Status][Discuss] Description 李哲非常非常喜欢柠檬树,特别是在静静的夜晚,当天空中有一弯明月温柔地照亮地面上的景物时,他必会悠闲地 坐在他亲手植下的那棵柠檬树旁,独自思索着人生的哲理.李哲是一个喜爱思考的孩子,当他看到在月光的照射下 柠檬树投在地面上的影子是如此的清晰,马上想到了一个问…
题目:https://www.luogu.org/problemnew/show/P4525 https://www.luogu.org/problemnew/show/P4526 学习辛普森积分:https://blog.csdn.net/VictoryCzt/article/details/80660113 代码如下: #include<cstdio> #include<cstring> #include<algorithm> #include<cmath&g…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1724 #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #define db double using namespace std; ; int T;db a,b,l,r; db f(db x){-x*x/a)*b);} db cal(db l,db r){*f((l+r)/…
Ellipse Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1868    Accepted Submission(s): 792 Problem Description Math is important!! Many students failed in 2+2’s mathematical test, so let's AC t…
Problem Description Math is important!! Many students failed in 2+2’s mathematical test, so let's AC this problem to mourn for our lost youth..Look this sample picture: A ellipses in the plane and center in point O. the L,R lines will be vertical thr…
[题目分析] 一看题目,直接把椭圆积分起来就可以了嘛. 然后发现椭圆比较难积分,还是算了吧. 用Simpson积分硬上. 大概就是用二次函数去拟合面积. [代码] #include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <map> #include <set> #include <queue> #include &l…
原文链接https://www.cnblogs.com/zhouzhendong/p/BZOJ2178.html 题目传送门 - BZOJ2178 题意 给出 $n(n\leq 1000)$ 个圆,求面积并. 所有圆的圆心坐标和半径都是绝对值不大于 1000 的整数. 题解 自适应辛普森积分模板题.注意先删掉被其他圆包含的圆. 但是 bzoj 大概是加过数据了,网上大部分直接自适应辛普森的代码都 TLE 了. 有一种卡常方法效果很好: 把 x 坐标按照整点划分成 $O(1000)$ 个区间,对于…
[BZOJ2178]圆的面积并(辛普森积分) 题面 BZOJ 权限题 题解 把\(f(x)\)设为\(x\)和所有圆交的线段的并的和. 然后直接上自适应辛普森积分. 我精度死活一个点过不去,不要在意我打表. #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> using namespace std; #define eps 1e-8 #define MAX 1010…
http://acm.hdu.edu.cn/showproblem.php?pid=1071 解一个给定三个点的坐标二次函数某区域的积分值. 设出方程之后高斯消元得到二次函数.然后再消元得到直线. 两次积分然后相减就可以了. 把自适应辛普森改成了传入函数指针的形式,有点多此一举. 可以这样做的原因,是因为这道题保证要求的区域都是在第一象限,否则不能直接定积分. 语言:G++ #include<bits/stdc++.h> using namespace std; typedef long lo…
题目描述 计算积分 结果保留至小数点后6位. 数据保证计算过程中分母不为0且积分能够收敛. 输入输出格式 输入格式: 一行,包含6个实数a,b,c,d,L,R 输出格式: 一行,积分值,保留至小数点后6位. 输入输出样例 输入样例#1: 复制 1 2 3 4 5 6 输出样例#1: 复制 2.732937 说明 a,b,c,d∈[-10,10] -100≤L<R≤100 且 R-L≥1 辛普森积分是用$y = Ax^2 +Bx +c$去拟合给定的函数 $$\int_a^bf(x)dx\appro…
题目描述 计算积分 保留至小数点后5位.若积分发散,请输出"orz". 输入输出格式 输入格式: 一行,包含一个实数,为a的值 输出格式: 一行,积分值或orz 输入输出样例 输入样例#1: 复制 2.33 输出样例#1: 复制 1.51068 说明 a<=50 请注意时空限制. 观察到函数具有极强的收敛性 然后估算一下上界,直接上辛普森积分 // luogu-judger-enable-o2 #include<cstdio> #include<cmath>…
辛普森积分法 - 维基百科,自由的百科全书 Simpson's rule - Wikipedia, the free encyclopedia 利用这个公式,用二分的方法来计算积分. 1071 ( The area ) #include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> using namespace std;…
1502: [NOI2005]月下柠檬树 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1017  Solved: 562[Submit][Status][Discuss] Description Input 文件的第1行包含一个整数n和一个实数alpha,表示柠檬树的层数和月亮的光线与地面夹角(单位为弧度).第2行包含n+1个实数h0,h1,h2,…,hn,表示树离地的高度和每层的高度.第3行包含n个实数r1,r2,…,rn,表示柠檬树每层下底面的…
参考:https://phqghume.github.io/2018/05/19/%E8%87%AA%E9%80%82%E5%BA%94%E8%BE%9B%E6%99%AE%E6%A3%AE%E6%B3%95/ 以及洛谷不多的题解. 辛普森推导过程就看参考吧,当然你要想看懂推导需要: 1.会高中导数那点东西,至少知道原函数怎么求. 2.粗略了解定积分. 3.知道微积分第一.第二基本定理(从知乎上找的:https://www.zhihu.com/question/21439225). 然后推导就很…
P4526 [模板]自适应辛普森法2 洛谷传送门 题目描述 计算积分 保留至小数点后5位.若积分发散,请输出"orz". 输入格式 一行,包含一个实数,为a的值 输出格式 一行,积分值或orz 输入输出样例 输入 #1复制 2.33 输出 #1复制 1.51068 说明/提示 a<=50 请注意时空限制. Solution 这和辛普森公式又啥关系?上限可是正无穷! 带着好奇心,我打开了几何画板. 几何画板 这……这么快就收敛了?!?!?! 看看a=50? 随便把B放在3边上.结果…
洛谷P4525 [模板]自适应辛普森法1 与P4526[模板]自适应辛普森法2 P4525洛谷传送门 P4525题目描述 计算积分 结果保留至小数点后6位. 数据保证计算过程中分母不为0且积分能够收敛. 输入格式 一行,包含6个实数a,b,c,d,L,R 输出格式 一行,积分值,保留至小数点后6位. 输入输出样例 输入 #1复制 1 2 3 4 5 6 输出 #1复制 2.732937 我的理解 求面积 说明/提示 a,b,c,d∈[-10,10] -100≤L<R≤100 且 R-L≥1 So…
LINK:自适应辛普森法1 观察题目 这个东西 凭借我们的数学知识应该是化简不了的. 可以直接认为是一个函数 求定积分直接使用辛普森就行辣. 一种写法: double a,b,c,d; double f(double x){ return (c*x+d)/(a*x+b); } //区间[a,b]上的辛普森值 double simpson(double a,double b){ double c=a+(b-a)/2; return (f(a)+4*f(c)+f(b))*(b-a)/6; } //区…
uva 1356 Bridge ( 辛普森积分 ) 不要问我辛普森怎么来的,其实我也不知道... #include<stdio.h> #include<math.h> #include<string.h> #include<algorithm> using namespace std ; double d , h , m , b , l , w ; double f ( double x ) { double a = 4.0 * m / w / w ; re…
自适应Simpson积分 作用 如标题所示,这玩意就是当你不会微积分的时候来求积分的. 总所周知,积分的定义就是函数的某一段与坐标轴之间的面积. 那么,自适应Simpson积分就是一种可以再某些精度下计算出较为平滑的函数的积分的比较简单优美的算法. (PS:这玩意的时间复杂度?大概是O(玄学)吧) 引子 积分的定义是面积,那么我们可以通过最基本的切割法来求出一定精度下面积. (ps:就是0.0000--01那样扫过去,把这个当做宽,把函数值当做高,然后乘起来当做面积) 然而这个耗费的时间太多,而…
1261: 地狱飞龙 时间限制: 1 秒  内存限制: 64 MB 提交: 300  解决: 68 题目描述 最近clover迷上了皇室战争,他抽到了一种地狱飞龙,很开心.假设地域飞龙会对距离为d的敌人每秒造成k/d2伤害.假设地域飞龙位于坐标轴原点,以每秒v1的速度向y轴正方向移动,敌人在(x,0)的位置,以每秒v2的速度向x轴负方向移动.问,敌人至少有多少血量永远才不会被地狱飞龙喷死.(伤害是连续造成的,不是一秒一秒间断的) 输入 第一行为数据组数T(1<=T<=1000) 每组数据一行,…