Codeforces Round #409(Div.2)
传送门
题意
A.询问最多改变一个字符的字符串“VK”子串数量
B.f(x,z)=y,给出x,y,求z
For example, f("ab", "ba") = "aa", and f("nzwzl", "zizez") = "niwel".
C.一个充电器充电\(p/min\),n台机器消耗电\(a_i/min\),一开始每台机器拥有电\(b_i\),问最多能使所有机器运行时间(一台机器停止则停止计时)
D.给出一个n角凸多边形,问每个点最多能移动多少距离保持多边形的凸性
分析
A.模拟
B.模拟
C.
如果可以用x秒,显然小于x秒时也可使用。故考虑二分时间。
得到了时间,我们就可以算出p的贡献为pt。
然后遍历每台机器,若cost[i]t > stored[i], 说明这台机器需要分配资源。
所有机器分配完之后的总资源还大于等于0则说明可以运行到t。
需要注意的是,这题eps = -4, 二分上界为1e11才过= =..二分浮点还是老老实实for个百遍
D.
考虑顶点i,若移动此点,则(i-1+n)%n, (i+1)%n也得动。
极限情况下这三点构成的三角形会退化成直线。
由于退化后这个三角形的周长其实是均摊到原图的,原图的周长不变,所以在纸上画一画发现其实就是原三角形把高一半处上方的三角形用高截成了两半,然后分到两边填充。
所以只需要算出这个高,答案就是所有高中最短的/2。
至于高的计算可以通过余弦定理算出cos,得到sin然后算出面积,除以底得到。或者用海伦公式
trick
代码
只给出C,D代码
C.
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define ll long long
#define F(i,a,b) for(int i=a;i<=b;++i)
#define mem(a,b) memset(a,b,sizeof(a))
int n;
double t,l,r,p;
struct node
{
double a,b,value;
bool operator<(const node &p)const
{
return value<p.value;
}
}c[100100];
double v[100100];
int main()
{
scanf("%d %lf",&n,&p);
for(int i=1;i<=n;++i)
{
scanf("%lf %lf",&c[i].a,&c[i].b);
c[i].value=c[i].b/c[i].a;
}
sort(c+1,c+1+n);
//for(int i=1;i<=n;++i) printf("%f %f\n",c[i].a,c[i].b);
for(int i=1;i<=n;++i) v[i]=c[i].value;
l=0,r=1e15;
for(int i=1;i<=1000;++i)
{
double mid=(l+r)/2,suma=0,sumb=0;
bool flag=1;
int loc=lower_bound(v+1,v+1+n,mid)-v;
//printf("loc=%d ",loc);
for(int j=1;j<loc;++j)
{
suma+=c[j].a;sumb+=c[j].b;
if((p*mid+sumb)<suma*mid) { flag=0;break; }
}
//printf("%d\n",flag);
//if(flag==1) printf("%f %f %f\n",p*mid+sumb,suma*mid,mid);
if(flag) l=mid;else r=mid;
}
if(l==1e15) { puts("-1");return 0; }
printf("%f\n",(l+r)/2);
}
D.
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i(a); i <= (b); ++i)
#define dec(i, a, b) for (int i(a); i >= (b); --i)
double x[100010], y[100010];
int n;
int main(){
scanf("%d", &n);
rep(i, 1, n){
scanf("%lf%lf", x + i, y + i);
}
x[++n] = x[1], y[n] = y[1];
x[++n] = x[2], y[n] = y[2];
x[++n] = x[3], y[n] = y[3];
double ans = 1e9;
rep(i, 1, n - 2){
double cnt = fabs((x[i + 1] - x[i]) * (y[i + 2] - y[i]) - (x[i + 2] - x[i]) * (y[i + 1] - y[i])) / 2;
double et = cnt / sqrt((x[i] - x[i + 2]) * (x[i] - x[i + 2]) + (y[i] - y[i + 2]) * (y[i] - y[i + 2]));
ans = min(ans, et);
}
printf("%.9f\n", ans);
return 0;
}
Codeforces Round #409(Div.2)的更多相关文章
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #262 (Div. 2) 1003
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...
- Codeforces Round #262 (Div. 2) 1004
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
- Codeforces Round #268 (Div. 2) ABCD
CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
随机推荐
- windows7 下安装使用memcached
Memcached 安装使用 本地环境:Windows7 64位web环境:wamp集成环境,php版本:PHP Version 7.1.17 学习参考网站: RUNOOB.COM官网 http:/ ...
- excludepathpatterns 无效
踩坑了,调了好久才调出来. 原因: 访问的API /XXX 已经转换为 /error 了. 把“/error” 也加入 excludepathpatterns 里面即可.
- POJ 2484 A Funny Game【博弈】
相比数据结构的题..感觉这种想啊想的题可爱多了~~~代码量还少.... 题目链接: http://poj.org/problem?id=2484 题意: 一圈n个硬币,两人轮流从中取一或两个硬币,(只 ...
- poj 3041——Asteroids
poj 3041——Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22604 Accep ...
- Win8系统如何在桌面行显示我的电脑
1 桌面右击-个性化 2 更改桌面图标-然后可以在桌面上显示需要的东西
- Android开发:怎样隐藏自己的app应用
本文主要介绍怎样通过改动AndroidManifest.xml清单文件来达到隐藏自身应用的目的,不是隐藏第三方应用.为了不浪费大家时间.特此说明. 转载请注明作者xiong_it和链接:http:// ...
- D广搜
<span style="color:#330099;">/* D - 广搜 基础 Time Limit:1000MS Memory Limit:30000KB 64b ...
- Spark应用远程调试
本来想用Eclipse的.然而在网上找了一圈,发现大家都在说IntelliJ怎样怎样好.我也受到了鼓励,遂决定在这台破机器上鼓捣一次IntelliJ吧. Spark程序远程调试,就是将本地IDE连接到 ...
- python的序列化和反序列化以及json
python 的序列化和反序列化用于内存之间的共享,包括服务器和客户端的共享,两个Python程序之间的共享,以及以字符串的形式存储到硬盘中. pyhton 的pickle 可以对Python的各种数 ...
- 【Mongodb教程 第七课 】MongoDB 查询文档
find() 方法 要从MongoDB 查询集合数据,需要使用MongoDB 的 find() 方法. 语法 基本的find()方法语法如下 >db.COLLECTION_NAME.find() ...
