【April Fools Day Contest 2014E】【简单计算几何】Dome 四棱锥内切圆半径为r

本文提供了一种求解四棱锥内切球半径问题的算法实现,通过循环遍历可能的整数解,找到满足条件的整数对,并输出结果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

E. Dome
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Input

The input contains a single floating-point number x with exactly 6 decimal places (0 < x < 5).

Output

Output two integers separated by a single space. Each integer should be between 1 and 10, inclusive. If several solutions exist, output any of them. Solution will exist for all tests.

Examples
input
1.200000
output
3 2
input
2.572479
output
10 3
input
4.024922
output
9 9
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x,y) memcpy(x,y,sizeof(x))
#define MP(x,y) make_pair(x,y)
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b>a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b<a)a = b; }
const int N = 0, M = 0, Z = 1e9 + 7, ms63 = 0x3f3f3f3f;
const double eps = 1e-6;
int n, m;
double ans;
void solve()
{
	for (int a = 1; a <= 10; ++a)
	{
		for (int h = 1; h <= 10; ++h)
		{
			double area = (a / 2.0*h);
			double bot = sqrt(a*a / 4.0 + h*h);
			double tmp = area / bot;
			if (fabs(tmp - ans) < eps)
			{
				printf("%d %d\n", a, h);
				return;
			}
		}
	}
}
int main()
{
	while (~scanf("%lf", &ans))
	{
		solve();
	}
	return 0;
}
/*
【题意】
什么样的四棱锥的内切球的半径可以为ans呢?
我们暴力一下就好啦


*/



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值