Kattis - amsterdamdistance【数学】
Kattis - amsterdamdistance【数学】
题意
给出两个点 算出从第一个点到第二个点的最短距离,只不过这里不是直角坐标系, 是雷达图
思路
因为内圈的圆的路径要比外圈的小,所以我们要尽可能先往内圈走,加一个判断条件 走到哪里就好了
AC代码
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <cstdlib>
#include <ctype.h>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long LL;
const double PI = 3.14159265358979323846264338327;
const double E = 2.718281828459;
const double eps = 1e-6;
const int MAXN = 0x3f3f3f3f;
const int MINN = 0xc0c0c0c0;
const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;
int main()
{
int n, m;
double r;
scanf("%d%d%lf", &n, &m, &r);
double ave = r * 1.0 / m;
int x1, y1, x2, y2;
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
double ans = 0.0;
ans += (max(y1, y2) - min(y1, y2)) * ave * 1.0;
int y = min(y1, y2);
double rec = (max(x1, x2) - min(x1, x2)) * 1.0 / n; // 份数
while (y)
{
double dis1, dis2;
dis1 = 2.0 * ave + 1.0 * rec * (PI * (y - 1) * ave);
dis2 = rec * PI * y * ave * 1.0;
if (dis1 <= dis2)
{
ans += 2 * ave;
y--;
}
else
{
ans += dis2;
break;
}
}
if (fabs(ans - 0.0) < eps)
cout << 0 << endl;
else
printf("%.14lf\n", ans);
}
Kattis - amsterdamdistance【数学】的更多相关文章
- Kattis - wheretolive 【数学--求质心】
Kattis - wheretolive [数学] Description Moving to a new town can be difficult. Finding a good place to ...
- A - Piece of Cake Kattis - pieceofcake (数学)
题目链接: A - Piece of Cake Kattis - pieceofcake 题目大意:给你一个多边形,然后给你这个多边形的每个点的坐标,让你从这个n个点中选出k个点,问这个k个点形成的面 ...
- Kattis - convexpolygonarea 【数学】
题意 给出一系列点,求这个多边形面积 思路 向量叉积 AC代码 #include <cstdio> #include <cstring> #include <ctype. ...
- Kattis - triangle 【数学】
题意 求第N个迭代三角形 中 所有黑色三角形的周长的整数部分的位数 思路 该三角形的周长是 3^(n + 1)/ 2 ^ (n) 然后 可以用 long double 存下来 再求位数 就可以 AC ...
- Kattis - friday 【数学】
题意 每一年的第一天 都是星期天 然后 给出 一年的总天数 和 总月数 以及 每个月 的总天数 求出 有多少个星期五 是当月的13号 思路 对于 每个月 只要判断 当月的13号 是不是 星期五 就可以 ...
- 数学思想:为何我们把 x²读作x平方
要弄清楚这个问题,我们得先认识一个人.古希腊大数学家 欧多克索斯,其在整个古代仅次于阿基米德,是一位天文学家.医生.几何学家.立法家和地理学家. 为何我们把 x²读作x平方呢? 古希腊时代,越来越多的 ...
- 速算1/Sqrt(x)背后的数学原理
概述 平方根倒数速算法,是用于快速计算1/Sqrt(x)的值的一种算法,在这里x需取符合IEEE 754标准格式的32位正浮点数.让我们先来看这段代码: float Q_rsqrt( float nu ...
- MarkDown+LaTex 数学内容编辑样例收集
$\color{green}{MarkDown+LaTex 数学内容编辑样例收集}$ 1.大小标题的居中,大小,颜色 [例1] $\color{Blue}{一元二次方程根的分布}$ $\color{R ...
- 深度学习笔记——PCA原理与数学推倒详解
PCA目的:这里举个例子,如果假设我有m个点,{x(1),...,x(m)},那么我要将它们存在我的内存中,或者要对着m个点进行一次机器学习,但是这m个点的维度太大了,如果要进行机器学习的话参数太多, ...
随机推荐
- MongoDB的容量规划及硬件配置
mongo是基于内存的数据库,应尽量将工作集中的数据全部加载到内存中,即内存应大于工作集 本文译自Chad Tindel的英文博客: http://www.mongodb.com/blog/post/ ...
- php 相同的产品 一个背景色
Array ( [0] => 12 [1] => 17 [2] => 17 [3] => 17 [4] => 17 [5] => 3 [6] => 3 [7] ...
- tcpdf
将文档整为pdf格式文档 网址:http://www.tcpdf.org/examples.php
- 【转】VC++的Unicode编程
转自http://www.cnblogs.com/kex1n/archive/2010/03/15/2286510.html 原始出处http://www.vckbase.com/document/v ...
- ubuntu16.04主题美化和软件推荐(转载)
从这里转载!转载!转载! http://blog.csdn.net/terence1212/article/details/52270210
- django 之 常用命令
Django 基本命令 本节主要是为了让您了解一些django最基本的命令,请尝试着记住它们,并且多多练习下 1. 新建一个 django project django-admin.py startp ...
- python技巧之下划线(一)
1.python的moudles文件中__all__作用 Python的moudle是很重要的一个概念,我看到好多人写的moudle里都有一个__init__.py文件.有的__init__.py中是 ...
- iOS nsstring 截取字符前后字符串
// Str = @"PEK_LHR" NSRange range = [trafficeStr rangeOfString:@"_" options:NSBa ...
- GIT界的神探--bisect
GIT界的神探--bisect 今天我们需要使用git命令中的bisect破获一起凶杀案,下面请看具体案件: 在一个git仓库中有a,b,c,d,e,f,g,h,i,j,k这几个提交,在k提交中发现软 ...
- 巨蟒python全栈开发flask4
1.偏函数 2.ThreadingLocal线程安全 空间换取时间 3.LocalStack 4.RunFlask+request 5.请求上文 6.请求下文