传送门

题意

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)的更多相关文章

  1. 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 ...

  2. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  3. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  4. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  5. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  6. 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 ...

  7. 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 ...

  8. Codeforces Round #371 (Div. 1)

    A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...

  9. Codeforces Round #268 (Div. 2) ABCD

    CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...

随机推荐

  1. SQL SERVER 2012 第四章 连接 JOIN の INNER JOIN

    所有JOIN语句的共同点是:将一个记录与另外一个或多个记录匹配,从而生成一个新记录,这个记录是由两个记录的合并列所产生的一个超集. 内部连接: 内部连接语法结构:SELECT <select l ...

  2. python学习之-- redis模块操作 HASH

    redis 操作 之 -Hash Hash 操作:hash在内存中的存储格式 name hash n1 ------> k1 -> v1 k2 -> v2 k3 -> v3hs ...

  3. [Bzoj4722]由乃(线段树好题)(倍增处理模数小快速幂)

    4722: 由乃 Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 360  Solved: 131[Submit][Status][Discuss] D ...

  4. Java连接MySQL报错:CommunicationsException: Communications link failure

    现象: 报错:Exception in thread "main" com.mysql.cj.jdbc.exceptions.CommunicationsException: Co ...

  5. vue学习001 --环境搭建

    系统 : win cmd: cmder 链接:https://cmder.net/ 1.安装node.js 链接地址: http://cdn.npm.taobao.org/dist/node/v10. ...

  6. openstack swift memcached

    如果生成的token总变,说明没有启动memcached: swift@vincent-virtual-machine /usr/bin $ memcached -p 11211 -m 64m -d ...

  7. Java描述符(修饰符)的类型

    以下内容引用自http://wiki.jikexueyuan.com/project/java/modifier-types.html: 描述符(修饰符)是添加到那些定义中来改变他们的意思的关键词.J ...

  8. mysql查看存储过程show procedure status;

    1.mysql查看存储过程(函数) 2.MySQL查看触发器 查看触发器 语法:SHOW TRIGGERS [FROM db_name] [LIKE expr] 实例:SHOW TRIGGERS\G ...

  9. wikioi 2147 bitset+map解决

    题目描写叙述 Description 小明是一名天文爱好者,他喜欢晚上看星星.这天,他从淘宝上买下来了一个高级望远镜.他十分开心.于是他晚上去操场上看星星. 不同的星星发出不同的光,他的望远镜能够计算 ...

  10. 矩阵奇异值分解(SVD)

    转自:https://www.cnblogs.com/LeftNotEasy/archive/2011/01/19/svd-and-applications.html  (感谢,讲解的太好了) 在机器 ...