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 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
随机推荐
- Mysqli的常用函数
Mysqli的常用函数 连接数据库: $res = @mysqli_connect($host,$username,$pass,$db_name); if (mysqli_connect_errno( ...
- JFinal Weixin 1.5 发布,微信极速 SDK
原文:http://www.oschina.net/news/67980/jfinal-weixin-1-5-released JFinal Weixin 1.5 大幅完善了对微信公众平台API的支持 ...
- HDU 6311 最少路径覆盖边集 欧拉路径
Cover Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- CSY版最大团,速度快一倍
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i(0); i < (n); ++i) ...
- Spring MVC页面重定向实例
以下内容引用自http://wiki.jikexueyuan.com/project/spring/mvc-framework/spring-page-redirection-example.html ...
- Java SpringMVC实现PC端网页微信扫码支付完整版
一:前期微信支付扫盲知识 前提条件是已经有申请了微信支付功能的公众号,然后我们需要得到公众号APPID和微信商户号,这个分别在微信公众号和微信支付商家平台上面可以发现.其实在你申请成功支付功能之后,微 ...
- Intellij IDEA远程调试tomcat
1.windows系统 文件catalina.bat首行增加下面代码 set CATALINA_OPTS=-server -Xdebug -Xnoagent -Djava.compiler=NONE ...
- Linux-github 搭建静态博客
1.在Github上创建一个新的Repository 到你的github上 https://github.com去create a new repository命名为 github.myblog 2. ...
- C#中泛型方法与泛型接口 C#泛型接口 List<IAll> arssr = new List<IAll>(); interface IPerson<T> c# List<接口>小技巧 泛型接口协变逆变的几个问题
http://blog.csdn.net/aladdinty/article/details/3486532 using System; using System.Collections.Generi ...
- C++11,控制台输出的一段小程序。
#include <iostream> // std::cout, std::boolalpha, std::noboolalpha int main () { bool b = true ...
