zoukankan      html  css  js  c++  java
  • Ellipse HDU

    Ellipse

    HDU - 1724
    emmm...快比赛了先补几个模板~
    自适应辛普森积分
     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 const double eps = 1e-5;
     4 double a, b, l, r;
     5 
     6 double F(double x) {
     7     //Simpson公式用到的函数
     8     return sqrt((a * a * b * b - b * b * x * x) / a / a);
     9 }
    10 double simpson(double a, double b) {  //三点Simpson法,这里要求F是一个全局函数
    11     double c = a + (b - a) / 2;
    12     return (F(a) + 4 * F(c) + F(b))*(b - a) / 6;
    13 }
    14 double asr(double a, double b, double eps, double A) { //自适应Simpson公式(递归过程)。已知整个区间[a,b]上的三点Simpson值A
    15     double c = a + (b - a) / 2;
    16     double L = simpson(a, c), R = simpson(c, b);
    17     if (fabs(L + R - A) <= 15 * eps)return L + R + (L + R - A) / 15.0;
    18     return asr(a, c, eps / 2, L) + asr(c, b, eps / 2, R);
    19 }
    20 double asr(double a, double b, double eps) { 
    21     return asr(a, b, eps, simpson(a, b));
    22 }
    23 
    24 
    25 int main(){
    26     int n;
    27     //freopen("in.txt", "r", stdin);
    28     scanf("%d", &n);
    29     for(int i = 0; i < n; i++){
    30         scanf("%lf %lf %lf %lf", &a, &b, &l, &r);
    31         printf("%.3lf
    ", 2 *asr(l, r, eps));
    32     }
    33 }
    View Code
  • 相关阅读:
    基本Dos命令
    安装java开发环境
    windouws常用快捷键
    elasticsearch(ES)
    使用kibana操作elasticsearch(es)
    Dubbo的负载均衡
    springboot结合Dubbo的使用
    Dubbo
    zookeeper-理解
    springboot结合FTP服务器实现文件上传
  • 原文地址:https://www.cnblogs.com/yijiull/p/7712368.html
Copyright © 2011-2022 走看看