热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

lightoj1022&&1072&&1107&&1118&&1178&&1216【基础计算几何】

1022-CircleinSquarePDF(English)StatisticsForumTimeLimit:0.5second(s)MemoryLimit:32MBA

1022 - Circle in Square
    PDF (English) Statistics Forum
Time Limit: 0.5 second(s) Memory Limit: 32 MB

A circle is placed perfectly into a square. The term perfectly placed means that each side of the square is touched by the circle, but the circle doesn't have any overlapping part with the square. See the picture below.


Now you are given the radius of the circle. You have to find the area of the shaded region (blue part). Assume that pi = 2 * acos (0.0) (acos means cos inverse).

Input

Input starts with an integer T (≤ 1000), denoting the number of test cases.

Each case contains a floating point number r (0  denoting the radius of the circle. And you can assume that r contains at most four digits after the decimal point.

Output

For each case, print the case number and the shaded area rounded to two places after the decimal point.

Sample Input

Output for Sample Input

3

20

30.091

87.0921

Case 1: 343.36

Case 2: 777.26

Case 3: 6511.05

Note

This problem doesn't have special judge. So, be careful about precision problems. Better to add a small value to your result to avoid precision problems. For example, add 10-9 to your result.


#include
#include
#include
#include
#include
#include
#include
#include
#include
#define PI acos(-1.0)
using namespace std;
int main()
{
int t,test=1;
double r;
scanf("%d",&t);
while(t--){
scanf("%lf",&r);
printf("Case %d: %.2lf\n",test++,4.0*r*r-PI*r*r);
}
return 0;
}


1072 - Calm Down
    PDF (English) Statistics Forum
Time Limit: 2 second(s) Memory Limit: 32 MB

George B. wants to be more than just a good American. He wants to make his daddy proud and become a hero. You know, like Shakib Khan.

But sneaky as he is, he wants a special revolver that will allow him to shoot more often than just the usual six times. This way he can fool and kill the enemy easily (at least that's what he thinks, and that's the best he can think). George has kidnapped . . . uh, I mean . . . "invited" you and will only let you go if you help him with the math. The piece of the revolver that contains the bullets looks like this (examples for 6 and 17 bullets):


There is a large circle with radius R and n little circles each having radius r, are placed inside on the border of the large circle. George wants his bullets to be as large as possible, so there should be no space between the circles. George will decide how large the whole revolver will be and how many bullets it shall contain. Your job is, given R and n, to compute r. You have decided to help, because you know that an idiot can't make a revolver even if you help him with the math.

Input

Input starts with an integer T (≤ 125), denoting the number of test cases.

Each case contains a real number R (0  and contains up to at most two places after the decimal point) and an integer n (2 ≤ n ≤ 100).

Output

For each test case, print the case number and r in a single line. Errors less than 10-6 will be ignored.

Sample Input

Output for Sample Input

4

4.0 6

4.0 17

3.14 100

42 2

Case 1: 1.3333333333

Case 2: 0.6209067545

Case 3: 0.0956260953

Case 4: 21

 

求出两圆心与大圆圆心的夹角列方程求解即可

#include
#include
#include
#include
#include
#include
#include
#include
#include
#define PI acos(-1.0)
using namespace std;
int main()
{
int t,i,j,k,test=1;
double r,n;
scanf("%d",&t);
while(t--){
scanf("%lf%lf",&r,&n);
double angle=2.0*PI/n;
printf("Case %d: %.7lf\n",test++,(r*sin(angle/2.0)/(1+sin(angle/2.0))));
}
return 0;
}

1107 - How Cow
    PDF (English) Statistics Forum
Time Limit: 2 second(s) Memory Limit: 32 MB

Mr Kopa Samsu is a farmer. He has a land of rectangular shape. But there are cows that disturb him a lot. The cows use to enter his land and ruin his crops. Now Mr Kopa Samsu has become smarter. He has a GPS system that will help him to know the position of the cows. So, you can think his land as a 2D grid, and cows can be treated as points. Now you are given the information of his land and cows. You have to tell him whether a cow is inside his land or not.

Input

Input starts with an integer T (≤ 50), denoting the number of test cases.

The first line of each case contains four integers x1 y1 x2 y2, where (x1, y1) is the lower left coordinate of his land and (x2, y2) is the upper right coordinate of his land. You can assume that the sides of the land are axis parallel. The next line contains an integer M (1 ≤ M ≤ 100) denoting the number of cows. Each of the next M lines contains two integers each denoting x y - the position of a cow. You can safely assume that no cow will lie on the boundary of the rectangle. All the coordinates will lie in the range [0, 10000].

Output

For each case you have to print the case number in a line first. Then for each cow, you have to print 'Yes' or 'No' depending whether the cow is inside the land or not.

Sample Input

Output for Sample Input

1

1 2 8 10

7

0 0

5 6

1 0

7 9

3 5

10 10

1 11

Case 1:

No

Yes

No

Yes

Yes

No

No

 


#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
const int maxn=10010;
int main()
{
int x1,x2,y1,y2,t,x,y,test=1;
scanf("%d",&t);
while(t--){
int n,i;
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
scanf("%d",&n);
printf("Case %d:\n",test++);
for(i=0;iscanf("%d%d",&x,&y);
if(x>=x1&&x<=x2&&y>=y1&&y<=y2){
printf("Yes\n");
}else {
printf("No\n");
}
}
}
return 0;
}


1118 - Incredible Molecules
    PDF (English) Statistics Forum
Time Limit: 0.5 second(s) Memory Limit: 32 MB

In the biological lab, you were examining some of the molecules. You got some interesting behavior about some of the molecules. There are some circular molecules, when two of them collide, they overlap with each other, and it's hard to find that which one is over the other one.

Given two molecules as circles, you have to find the common area of the given molecules that is shaded in the picture.


Overlapping Molecules

Input

Input starts with an integer T (≤ 12), denoting the number of test cases.

Each case contains six integers x1, y1, r1 and x2, y2, r2. Where (x1, y1) is the center of the first molecule and r1 is the radius and (x2, y2) is the center of the second molecule and r2 is the radius. Both the radiuses are positive. No integer will contain more than 3 digits.

Output

For each test case, print the case number and the common area of the given molecules. Errors less than 10-6 will be ignored.

Sample Input

Output for Sample Input

3

0 0 10 15 0 10

-10 -10 5 0 -10 10

100 100 20 100 110 20

Case 1: 45.3311753978

Case 2: 35.07666099

Case 3: 860.84369

 


两圆相交面积


#include
#include
#include
#include
#include
#include
#include
#include
#define eps 1e-6
#define PI acos(-1.0)
using namespace std;
double area(double x1,double y1,double r1,double x2,double y2,double r2){
double d=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
double angle1,angle2,h1,h2,s1,s2;
if(d>=r1+r2){
return 0;
}
if(d<=fabs(r1-r2)){
return min(PI*r1*r1,PI*r2*r2);
}
angle1=acos((d*d+r1*r1-r2*r2)/(2*d*r1));
angle2=acos((d*d+r2*r2-r1*r1)/(2*d*r2));
h1=angle1*r1*r1;h2=angle2*r2*r2;
s1=r1*r1*cos(angle1)*sin(angle1);
s2=r2*r2*cos(angle2)*sin(angle2);
return h1+h2-(s1+s2);
}
int main()
{
int t,test=1;
double x1,y1,x2,y2,r1,r2;
scanf("%d",&t);
while(t--){
scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&r1,&x2,&y2,&r2);
printf("Case %d: %.7lf\n",test++,area(x1,y1,r1,x2,y2,r2));
}
return 0;
}


1178 - Trapezium
    PDF (English) Statistics Forum
Time Limit: 0.5 second(s) Memory Limit: 32 MB

You are given the length of the four sides of a trapezium; you have to calculate the area. In geometry a 4-sided figure with exactly one pair of parallel sides is called a trapezium.


Input

Input starts with an integer T (≤ 20), denoting the number of test cases.

Each case contains four real numbers a b c d denoting the sides of the trapezium. Here a and c denote the parallel sides. You can safely assume that the given trapezium is valid. Each of the numbers will be positive and not more than 200. And no number contains more than 4 digits after the decimal point.

Output

For each case, print the case number and the area. Errors less than 10-6 will be ignored.

Sample Input

Output for Sample Input

2

6 5 12 5.0

9 5 6 4

Case 1: 36

Case 2: 30.0000000

 

#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
const int maxn=10010;
int main()
{
int t,test=1;
double a,b,c,d;
scanf("%d",&t);
while(t--){
scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
double x=fabs(a-c);
double p=(b+d+x)/2;
double tarea=sqrt(p*(p-d)*(p-b)*(p-x));
double h=tarea*2/x;
printf("Case %d: %.7lf\n",test++,min(a,c)*h+tarea);
}
return 0;
}

1216 - Juice in the Glass
    PDF (English) Statistics Forum
Time Limit: 2 second(s) Memory Limit: 32 MB

Once upon a time, there lived a mad programmer. He loved to solve creative problems other than anything. His wife loved him quite a lot but disliked his curiosity for the problems. One day he came from office, his wife gave him a glass of cold lime juice. She was in a romantic mood and waiting for some romantic stuff. But the programmer asked her curiously, "If I give u radius of the top and bottom part of the glass and the height, can you come up with the volume of the glass?" His wife became a bit disappointed but as she is smart she replied with a smile, "You already have drunk some juice, and the glass is not full. If I give you the height of the juice, can you find the volume of the remaining juice in the glass?" Then the programmer kissed his wife and said, "You are the best problem setter in the world!"


Now he set the same problem for you. The radius of the upper part r1 and lower part r2 is given. If height of the glass is h and height of the juice is p what is the volume of the juice in the glass?

Input

Input starts with an integer T (≤ 100), denoting the number of test cases.

Each case starts with a line containing four integers r1 r2 h p (1 ≤ r2 1 ≤ 100, 1 ≤ p ≤ h ≤ 100).

Output

For each case, print the case number and the volume of the juice in the glass. Errors less than 10-6 will be ignored.

Sample Input

Output for Sample Input

2

5 2 3 2

5 2 3 3

Case 1: 58.643062867

Case 2: 122.52211349

 

#include
#include
#include
#include
#include
#include
#include
#include
#include
#define PI acos(-1.0)
using namespace std;
int main()
{
int t,test=1;
double h,p,r1,r2;
scanf("%d",&t);
while(t--){
scanf("%lf%lf%lf%lf",&r1,&r2,&h,&p);
double H=(h/(r1-r2))*r1;
double r3=r2+((r1-r2)/h)*p;
double v1=PI*r3*r3*(H-h+p)/3.0;
double v2=PI*r2*r2*(H-h)/3.0;
printf("Case %d: %.7lf\n",test++,v1-v2);
}
return 0;
}



推荐阅读
  • 扫描线三巨头 hdu1928hdu 1255  hdu 1542 [POJ 1151]
    学习链接:http:blog.csdn.netlwt36articledetails48908031学习扫描线主要学习的是一种扫描的思想,后期可以求解很 ... [详细]
  • 本文详细介绍了如何在Linux系统上安装和配置Smokeping,以实现对网络链路质量的实时监控。通过详细的步骤和必要的依赖包安装,确保用户能够顺利完成部署并优化其网络性能监控。 ... [详细]
  • UNP 第9章:主机名与地址转换
    本章探讨了用于在主机名和数值地址之间进行转换的函数,如gethostbyname和gethostbyaddr。此外,还介绍了getservbyname和getservbyport函数,用于在服务器名和端口号之间进行转换。 ... [详细]
  • 题目Link题目学习link1题目学习link2题目学习link3%%%受益匪浅!-----&# ... [详细]
  • 本题涉及一棵由N个节点组成的树(共有N-1条边),初始时所有节点均为白色。题目要求处理两种操作:一是改变某个节点的颜色(从白变黑或从黑变白);二是查询从根节点到指定节点路径上的第一个黑色节点,若无则输出-1。 ... [详细]
  • 使用GDI的一些AIP函数我们可以轻易的绘制出简 ... [详细]
  • 优化ListView性能
    本文深入探讨了如何通过多种技术手段优化ListView的性能,包括视图复用、ViewHolder模式、分批加载数据、图片优化及内存管理等。这些方法能够显著提升应用的响应速度和用户体验。 ... [详细]
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ... [详细]
  • 本文介绍如何使用Objective-C结合dispatch库进行并发编程,以提高素数计数任务的效率。通过对比纯C代码与引入并发机制后的代码,展示dispatch库的强大功能。 ... [详细]
  • 主要用了2个类来实现的,话不多说,直接看运行结果,然后在奉上源代码1.Index.javaimportjava.awt.Color;im ... [详细]
  • C++: 实现基于类的四面体体积计算
    本文介绍如何使用C++编程语言,通过定义类和方法来计算由四个三维坐标点构成的四面体体积。文中详细解释了四面体体积的数学公式,并提供了两种不同的实现方式。 ... [详细]
  • 本文详细介绍了如何构建一个高效的UI管理系统,集中处理UI页面的打开、关闭、层级管理和页面跳转等问题。通过UIManager统一管理外部切换逻辑,实现功能逻辑分散化和代码复用,支持多人协作开发。 ... [详细]
  • This document outlines the recommended naming conventions for HTML attributes in Fast Components, focusing on readability and consistency with existing standards. ... [详细]
  • 本文探讨了 C++ 中普通数组和标准库类型 vector 的初始化方法。普通数组具有固定长度,而 vector 是一种可扩展的容器,允许动态调整大小。文章详细介绍了不同初始化方式及其应用场景,并提供了代码示例以加深理解。 ... [详细]
author-avatar
专业拍片
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有