oval-and-rectangle

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0

Problem Description
Patrick Star find an oval.
The half of longer axes is on the x-axis with length $a$.
The half of shorter axes is on the y-axis with length $b$.
Patrick Star plan to choose a real number $c$ randomly from $[0, b]$, after that, Patrick Star will get a rectangle :

1. The four vertexes of it are on the outline of the oval.
2. The two sides of it parallel to coordinate axis.
3. One of its side is $y = c$.
Patrick Star want to know the expectations of the rectangle's perimeter.

 
Input
The first line contain a integer $T$ (no morn than 10), the following is $T$ test case, for each test case :
Each line contains contains two integer a, b ($0 < b < a < 10^5$). Separated by an white space.
 
Output
For each test case output one line denotes the expectations of the rectangle's perimeter .
You should keep exactly 6 decimal digits and ignore the remain decimal digits.
It is guaranted that the 7-th decimal digit of answer wont be 0 or 9.
 
Sample Input
1
2 1
 
Sample Output
8.283185

分析:椭圆性质有:
将y=c带入,求出内接矩形的周长,通过积分求出答案。
ac代码:

 #include <iostream>
#include <cstdio>
using namespace std; int main()
{
int t;
cin>>t;
while(t--)
{
int a, b;
int x, y;
cin>>a>>b>>x>>y;
int w = b * (-) * x / a;
printf("%d\n", x/(w-y));
}
return ;
}

oval-and-rectangle的更多相关文章

  1. Android之shape属性详解

    有时候 ,为了满足一些需求,我们要用到 shape 去定义 一些背景,shape 的用法 跟图片一样 ,可以给View设置 Android:background="@drawable/sha ...

  2. 【Android 界面效果20】Android GradientDrawable类的详解,设置activity的背景颜色渐变效果

    看到这个例子的标题RoundRects,我的第一感觉是介绍RoundRectShape, 打开例子看了代码却是使用GradientDrawable来实现的. GradientDrawable 支持使用 ...

  3. Android GradientDrawable类的详解,设置activity的背景颜色渐变效果

    看到这个例子的标题RoundRects,我的第一感觉是介绍RoundRectShape, 打开例子看了代码却是使用GradientDrawable来实现的. GradientDrawable 支持使用 ...

  4. Android电子书翻页效果实现

    这篇文章是在参考了别人的博客基础上,修改了其中一个翻页bug,并且加了详细注释 先看效果 其中使用了贝赛尔曲线原理,关于贝赛尔曲线的知识,推荐大家看下http://blog.csdn.net/hmg2 ...

  5. Python Tkinter学习笔记

    介绍 入门实例 显示一个窗口,窗口里面有一个标签,显示文字 import tkinter as tk # 一个顶层窗口的实例(Top Level),也称为根窗口 app = tk.Tk() # 设置窗 ...

  6. Python Tkinter canvas oval原理

    Ovals, mathematically, are ellipses, including circles as a special case. The ellipse is fit into a ...

  7. [LeetCode] Perfect Rectangle 完美矩形

    Given N axis-aligned rectangles where N > 0, determine if they all together form an exact cover o ...

  8. [LeetCode] Max Sum of Rectangle No Larger Than K 最大矩阵和不超过K

    Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix s ...

  9. [LeetCode] Smallest Rectangle Enclosing Black Pixels 包含黑像素的最小矩阵

    An image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black ...

  10. [LeetCode] Rectangle Area 矩形面积

    Find the total area covered by two rectilinear rectangles in a2D plane. Each rectangle is defined by ...

随机推荐

  1. UEditor黑白名单配置

    在网上找了很多,都不对.自己尝试,代码如下: 在new UEditor之前加上: Object.assign(window.UEDITOR_CONFIG.whitList, { filling: [' ...

  2. [转] Shell编程之数组使用

    #!/bin/bash #基本数组操作a=(1 2 3) ##()表示空数组echo "第0个元素:"${a[0]}echo "所有元素: "${a[@]}ec ...

  3. Vs2017获取Git空仓库后创建解决方案及项目无法推送,推送失败的问题.

      与Git无关,因为远程是空文件夹,导致没有远程版本做对应提示更改或怎样,必须在创建人创建仓库的时候上传文件代码. https://developercommunity.visualstudio.c ...

  4. 【bzoj4031】[HEOI2015]小Z的房间

    题解: 矩阵树定理入门题 一个图的邻接矩阵G:对于无向图的边(u,v),G[u][v]++,G[v][u]++ 一个图的度数矩阵D:对于无向图的边(u,v),D[u][u]++,D[v][v]++; ...

  5. [转]GitHub for Windows 安装失败,An error occurred attempting to install github 的解决办法

    解决办法: 只需要将 http://github-windows.s3.amazonaws.com/GitHub.application http改为https,然后在IE上打开,安装即可 问题如下 ...

  6. 【Codeforces】Gym100633 D. LWDB

    题解 点分治,然后每个点上挂着一个距离不超过\(a_{i}\)的颜色改成\(c\) 用一个单调栈维护距离单调递减,每次查询在每个包括这个点的分治中心的单调栈上二分,找到修改最靠前的颜色作为这个点的颜色 ...

  7. 【Android】Android 设置Activity窗体 不显示标题和全屏显示

    [一]Android 设置Activity窗体 不显示标题 android:theme="@android:style/Theme.NoTitleBar" <activity ...

  8. rxjs简单入门

    rxjs全名Reactive Extensions for JavaScript,Javascript的响应式扩展, 响应式的思路是把随时间不断变化的数据.状态.事件等等转成可被观察的序列(Obser ...

  9. sql对于字符串的处理

  10. ELK安装(ubuntu)

    一.安装jdk8 经过我测试logstash5.x不支持java10和11,所以安装java8 加入LinuxUprising Java PPA sudo add-apt-repository ppa ...