Codeforces 101173 C - Convex Contour
思路:
如果所有的图形都是三角形,那么答案是2*n+1
否则轮廓肯定触到了最上面,要使轮廓线最短,那么轮廓肯定是中间一段平的
我们考虑先将轮廓线赋为2*n+2,然后删去左右两边多余的部分
如果最左边或最由边是正方形,那么不需要删
如果最左边或最由边是圆形,那么删取2 - pi/2
如果如果最左边或最由边是三角形,那么我们需要找到一段连续的三角形,然后考虑怎么删去
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head int main() {
fio;
int n;
string s;
cin >> n;
cin >> s;
bool f = true;
for (int i = ; i < n; i++) if(s[i] != 'T') f = false;
if(f) {
cout << *n + << endl;
}
else {
double ans = *n + ;
if(s[] == 'T') {
int x = ;
for (int i = ; i < n; i++) {
if(s[i] == 'T') {
x++;
}
else if(s[i] == 'C'){
double tot = x + 0.5;
double t = sqrt((sqrt()/ - 0.5)*(sqrt()/ - 0.5) + x*x - 0.25);
tot -= t;
double a = atan((sqrt()/ - 0.5) / x);
double b = atan(t*);
double c = pi/ -a - b;
tot -= c*0.5;
ans -= tot;
break;
}
else if(s[i] == 'S') {
double tot = x;
double t = sqrt((-sqrt()/)*(-sqrt()/) + (x-0.5) * (x-0.5));
tot -= t;
ans -= tot;
break;
}
}
}
else if(s[] == 'C') {
ans -= - pi/;
} reverse(s.begin(), s.end());
if(s[] == 'T') {
int x = ;
for (int i = ; i < n; i++) {
if(s[i] == 'T') {
x++;
}
else if(s[i] == 'C'){
double tot = x + 0.5;
double t = sqrt((sqrt()/ - 0.5)*(sqrt()/ - 0.5) + x*x - 0.25);
tot -= t;
double a = atan((sqrt()/ - 0.5) / x);
double b = atan(t*);
double c = pi/ -a - b;
tot -= c*0.5;
ans -= tot;
break;
}
else if(s[i] == 'S') {
double tot = x;
double t = sqrt((-sqrt()/)*(-sqrt()/) + (x-0.5) * (x-0.5));
tot -= t;
ans -= tot;
break;
}
}
}
else if(s[] == 'C') {
ans -= - pi/;
}
cout << fixed << setprecision() << ans << endl;
}
return ;
}
Codeforces 101173 C - Convex Contour的更多相关文章
- [CERC2016]:凸轮廓线Convex Contour(模拟+数学)
题目描述 一些几何图形整齐地在一个网格图上从左往右排成一列.它们占据了连续的一段横行,每个位置恰好一个几何图形.每个图形是以下的三种之一:$1.$一个恰好充满单个格子的正方形.$2.$一个内切于单个格 ...
- UVALive 7749 Convex Contour (计算几何)
题意:给定上正方形,圆,三角形,让你求出包围它的最短的路径. 析:首先,如果是这种情况 三角形 三角形 三角形 正方形(圆) 三角形 三角形 三角形 ..这一种就是直接从左边直接连到正方形(圆),也 ...
- 【计算几何】【分类讨论】Gym - 101173C - Convex Contour
注意等边三角形的上顶点是卡不到边界上的. 于是整个凸包分成三部分:左边的连续的三角形.中间的.右边的连续的三角形. 套个计算几何板子求个三角形顶点到圆的切线.三角形顶点到正方形左上角距离啥的就行了,分 ...
- codeforces B. Convex Shape 解题报告
题目链接:http://codeforces.com/problemset/problem/275/B 题目内容:给出一个n * m 大小的grid,上面只有 black 和 white 两种颜色填充 ...
- Codeforces 838E Convex Countour
题 OvO http://codeforces.com/contest/838/problem/E (IndiaHacks 2nd Elimination 2017 (unofficial, unra ...
- Codeforces.838E.Convex Countour(区间DP)
题目链接 \(Description\) 给定一个n边凸多边形(保证没有三点共线),求一条经过每个点最多一次的不会相交的路径,使得其长度最大.输出这个长度. \(Solution\) 最长路径应该是尽 ...
- Codeforces Round #270 1003
Codeforces Round #270 1003 C. Design Tutorial: Make It Nondeterministic time limit per test 2 second ...
- codeforces 70D Professor's task(动态二维凸包)
题目链接:http://codeforces.com/contest/70/problem/D Once a walrus professor Plato asked his programming ...
- Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel 打表数学
B. The Monster and the Squirrel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/c ...
随机推荐
- ORA-12052: cannot fast refresh materialized view
SQL> execute dbms_mview.refresh ('TX_FAIL_LOG_DAY_MV', 'f'); BEGIN DBMS_MVIEW.REFRESH ('TX_FAIL_L ...
- [J2EE]struts+ejb笔记
DispatchAtion: - org.apache.struts.actions.DispatchAction 这个类是个抽象类,但实现父类Action的execute方法,在项目中重写这个类可以 ...
- Mybatis的in使用
foreach元素的属性主要有 item,index,collection,open,separator,close. item表示集合中每一个元素进行迭代时的别名, index指 定一个 ...
- c++ vector常见用法
//输出尾巴的元素 cout<<vec.back(); //定义vector迭代器 vector<int>::iterator ite=vec.begin(); for(ite ...
- java Swing小知识点
private JTextArea jta=new JTextArea(1,2); private ScrollPane sp=new ScrollPane(); private JPasswordF ...
- 流程控制if,while,for
if语句 什么是if语句 判断一个条件如果成立则做...不成立则做....为何要有if语句 让计算机能够像人一样具有判断的能力 如何用if语句 语法1: if 条件1: code1 code2 cod ...
- 嵌入式电路中的BUCK VS LDO【转】
本文转载自:http://blog.chinaunix.net/uid-25906157-id-4125916.html 作为一名FAE,才知硬件知识的匮乏.慢慢积累一点儿硬件知识吧!BUCK和LDO ...
- 浅谈Log4j2日志框架及使用
目录 1.日志框架 2.为什么需要日志接口,直接使用具体的实现不就行了吗? 3.log4j2日志级别 4.log4j2配置文件的优先级 5.对于log4j2配置文件的理解 6.对于Appender的理 ...
- 【Dalston】【第七章】分布式链路跟踪(Sleuth)
当我们进行微服务架构开发时,通常会根据业务来划分微服务,各业务之间通过REST进行调用.一个用户操作,可能需要很多微服务的协同才能完成,如果在业务调用链路上任何一个微服务出现问题或者网络超时,都会导致 ...
- (转)Is attacking machine learning easier than defending it?
转自:http://www.cleverhans.io/security/privacy/ml/2017/02/15/why-attacking-machine-learning-is-easier- ...