大力辛普森积分 精度什么的搞了我好久- 学到了Simpson的一个trick 深度开11,eps开1e-4.跑的比有些扫描线还快- CODE #include <bits/stdc++.h> using namespace std; const int MAXN = 205; const double eps = 1e-10; inline double sqr(double x) { return x*x; } inline int dcmp(double x) { return x <…
1845: [Cqoi2005] 三角形面积并 Time Limit: 3 Sec  Memory Limit: 64 MBSubmit: 848  Solved: 206[Submit][Status][Discuss] Description 给出n个三角形,求它们并的面积. Input 第一行为n(N < = 100), 即三角形的个数 以下n行,每行6个整数x1, y1, x2, y2, x3, y3,代表三角形的顶点坐标.坐标均为不超过10 ^ 6的实数,输入数据保留1位小数 Outp…
1845: [Cqoi2005] 三角形面积并 Time Limit: 3 Sec  Memory Limit: 64 MBSubmit: 1151  Solved: 313[Submit][Status][Discuss] Description 给出n个三角形,求它们并的面积. Input 第一行为n(N < = 100), 即三角形的个数 以下n行,每行6个整数x1, y1, x2, y2, x3, y3,代表三角形的顶点坐标.坐标均为不超过10 ^ 6的实数,输入数据保留1位小数 Out…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2178 先看到这篇博客:https://www.cnblogs.com/heisenberg-/p/6740654.html 好像本应算弓形面积.三角形面积之类的,但不会...于是用辛普森积分硬做... 参考了这篇博客:https://blog.csdn.net/orpinex/article/details/7311363 然而如果写成精度友好型的 asr ( *15, /15, eps/…
2178: 圆的面积并 Time Limit: 20 Sec  Memory Limit: 259 MBSubmit: 1740  Solved: 450[Submit][Status][Discuss] Description 给出N个圆,求其面积并 Input 先给一个数字N ,N< = 1000 接下来是N行是圆的圆心,半径,其绝对值均为小于1000的整数 Output 面积并,保留三位小数 太可怕了!!!!!! 直接上辛普森积分 函数值就是x=..线上的区间并 区间并直接排序扫描就可以了…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2178 把包含的圆去掉.横坐标不相交的一段一段圆分开算.算辛普森的时候预处理 f( ) ,比如把自己的 f( l ) 和 f( r ) 从上一层传进来之类的,能少算很多次. #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #define db double us…
code #include <set> #include <cmath> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int MAXN = 1005; const double Pi = acos(-1.0); const double eps = 1e-12; const double INF = 1e12; inlin…
1845: [Cqoi2005] 三角形面积并 Time Limit: 3 Sec  Memory Limit: 64 MBSubmit: 1664  Solved: 443[Submit][Status][Discuss] Description 给出n个三角形,求它们并的面积. Input 第一行为n(N < = 100), 即三角形的个数 以下n行,每行6个整数x1, y1, x2, y2, x3, y3,代表三角形的顶点坐标.坐标均为不超过10 ^ 6的实数,输入数据保留1位小数 Out…
[CQOI2005]三角形面积并 题目大意: 求\(n(n\le100)\)个三角形的面积并. 思路: 自适应辛普森法,玄学卡精度可过. 源代码: #include<cmath> #include<cstdio> #include<cctype> #include<vector> #include<algorithm> inline int getint() { register char ch; while(!isdigit(ch=getcha…
[BZOJ1845][Cqoi2005] 三角形面积并 Description 给出n个三角形,求它们并的面积. Input 第一行为n(N < = 100), 即三角形的个数 以下n行,每行6个整数x1, y1, x2, y2, x3, y3,代表三角形的顶点坐标.坐标均为不超过10 ^ 6的实数,输入数据保留1位小数 Output 输出并的面积u, 保留两位小数 Sample Input 2 0.0 0.0 2.0 0.0 1.0 1.0 1.0 0.0 3.0 0.0 2.0 1.0 Sa…
1502: [NOI2005]月下柠檬树 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1070  Solved: 596[Submit][Status][Discuss] Description Input 文件的第1行包含一个整数n和一个实数alpha,表示柠檬树的层数和月亮的光线与地面夹角(单位为弧度).第2行包含n+1个实数h0,h1,h2,…,hn,表示树离地的高度和每层的高度.第3行包含n个实数r1,r2,…,rn,表示柠檬树每层下底面的…
欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ1845 题意概括 给出n个三角形,求其面积并. 题解 有一个很经典的扫描线题目:矩形面积并.那个比较简单,建议先去看看 —— 传送门 - 矩形面积并. 这个扫描线的算法,我之前就看过. 之前想了想,还以为是n4logn的,自己以为理解错了,所以就弃坑了一段时间. 现在再想想,原来之前思考的是对的,只是复杂度想错了.其实是n3logn的. 我们按照Y来排序,同样的,我们来看一组图片. 然后大概你已经…
求出所有交点后从左往右扫描线,用每段的中位线去截所有三角形,算出长度并后乘以该段长度即可,时间复杂度$O(n^3\log n)$. #include<cstdio> #include<cmath> #include<algorithm> using namespace std; const int N=310; const double eps=1e-9,inf=2000000; struct P{ double x,y; P(){x=y=0;} P(double _x…
[题目分析] 史上最良心样例,史上最难调样例. Simpson积分硬上. 听说用long double 精度1e-10才能过. 但是double+1e-6居然过了. [代码] #include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <map> #include <set> #include <queue> #incl…
题目链接:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1845 给定100个三角形,求三角形面积并. 戴神模板太可怕.直接调用函数秒掉.思路有点繁琐,不大清楚.贴一个代码. 代码: /* *********************************************** Author :rabbit Created Time :2014/7/3 22:46:38 File Name :2.cpp **************…
原文链接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…
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…
1502: [NOI2005]月下柠檬树 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1387  Solved: 739[Submit][Status][Discuss] Description 李哲非常非常喜欢柠檬树,特别是在静静的夜晚,当天空中有一弯明月温柔地照亮地面上的景物时,他必会悠闲地 坐在他亲手植下的那棵柠檬树旁,独自思索着人生的哲理.李哲是一个喜爱思考的孩子,当他看到在月光的照射下 柠檬树投在地面上的影子是如此的清晰,马上想到了一个问…
题目链接 题意 给出一个椭圆,问一个[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 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…
1058: 三角形面积 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 190  Solved: 128[Submit][Status][Web Board] Description 三角形面积=SQRT(S*(S-a)*(S-b)*(S-c)) 其中S=(a+b+c)/2,a.b.c为三角形的三边.定义两个带参的宏,一个用来求area,另一个宏用来求S. 写程序,在程序中用带实参的宏名来求面积area. Input a b c三角形的三条边,可以是…
Problem ATriangle Fun Input: Standard Input Output: Standard Output In the picture below you can see a triangle ABC. Point D, E and F divides the sides BC, CA and AB into ratio 1:2 respectively. That is CD=2BD, AE=2CE and BF=2AF. A, D; B, E and C, F…
/*============================================== 计算三角形面积 总时间限制: 1000ms 内存限制: 65536kB 描述 平面上有一个三角形,它的三个顶点坐标分别为(x1, y1), (x2, y2), (x3, y3),那么请问这个三角形的面积是多少. 输入 输入仅一行,包括6个单精度浮点数,分别对应x1, y1, x2, y2, x3, y3. 输出 输出也是一行,输出三角形的面积,精确到小数点后两位. 样例输入 0 0 4 0 0 3…
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…
三角形面积 时间限制:3000 ms  |  内存限制:65535 KB 难度:2   描述 给你三个点,表示一个三角形的三个顶点,现你的任务是求出该三角形的面积   输入 每行是一组测试数据,有6个整数x1,y1,x2,y2,x3,y3分别表示三个点的横纵坐标.(坐标值都在0到10000之间)输入0 0 0 0 0 0表示输入结束测试数据不超过10000组 输出 输出这三个点所代表的三角形的面积,结果精确到小数点后1位(即使是整数也要输出一位小数位) 样例输入 0 0 1 1 1 3 0 1…
三角形面积 时间限制:3000 ms  |  内存限制:65535 KB 难度:2   描述 给你三个点,表示一个三角形的三个顶点,现你的任务是求出该三角形的面积   输入 每行是一组测试数据,有6个整数x1,y1,x2,y2,x3,y3分别表示三个点的横纵坐标.(坐标值都在0到10000之间)输入0 0 0 0 0 0表示输入结束测试数据不超过10000组 输出 输出这三个点所代表的三角形的面积,结果精确到小数点后1位(即使是整数也要输出一位小数位) 样例输入 0 0 1 1 1 3 0 1…
描述 Background Hello Earthling. We're from the planet Regetni and need your help to make lots of money. Maybe we'll even give you some of it. You see, the problem is that in our world, everything is about integers. It's even enforced by law. No other…
Problem Description This is a simple problem. Given two triangles A and B, you should determine they are intersect, contain or disjoint. (Public edge or point are treated as intersect.)  Input First line contains an integer T (1 ≤ T ≤ 10), represents…
#include<stdio.h> #include<math.h> int main() { // 声明三角形的三个顶点坐标和面积 float x1, y1, x2, y2, x3, y3, s; // 输入坐标 scanf("%f %f %f %f %f %f",&x1, &y1, &x2, &y2, &x3, &y3); // 利用欧氏距离计算边长 float a, b, c; a=sqrt(1.0*(x2-…