会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
Free Man
博客园
|
首页
|
新随笔
|
新文章
|
联系
| |
管理
zoj1199
关键是要考虑到两个两个圆的直径r1==r2的情况和一个圆在另外一个圆内的情况。
顺便,c++输出格式的控制,cout << fixed表示固定小数点,cout << showpoint表示强制显示小数点,cout << setprecision(x)表示输出精度。如果没有cout << fixed作为前缀条件,那么setprecision(x)表示整个输出为数为x位。加上cout << fixed作为条件,那么setprecision(x)表示小数点的为数为x位。
Code
#include
<
iostream
>
#include
<
cmath
>
#include
<
iomanip
>
using
namespace
std;
int
main()
{
int
numberOfCase;
cin
>>
numberOfCase;
for
(
int
i
=
0
; i
<
numberOfCase; i
++
)
{
int
x1, y1, r1, x2, y2, r2;
cin
>>
x1
>>
y1
>>
r1
>>
x2
>>
y2
>>
r2;
double
d
=
sqrt((x1
-
x2)
*
(x1
-
x2)
+
(y1
-
y2)
*
(y1
-
y2));
if
((d
<=
fabs(r1
-
r2))
||
(x1
==
x2
&&
y1
==
y2)
||
(r1
==
r2))
cout
<<
"
Impossible.
"
<<
endl;
else
{
double
x
=
double
(r1
*
x2
-
r2
*
x1)
/
(r1
-
r2);
double
y
=
double
(r1
*
y2
-
r2
*
y1)
/
(r1
-
r2);
cout
<<
fixed
<<
showpoint;
cout
<<
setprecision(
2
)
<<
x
<<
'
'
<<
y
<<
endl;
}
}
return
0
;
}
发表于
2009-03-16 18:55
Lox
阅读(
208
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部