传送门

题意

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. 《TCP/IP详解卷1:协议》——第4章 ARP:地址解析协议(转载)

    章节回顾: 1.引言 当一台主机把以太网数据帧发送到位于同一局域网上的另一台主机时,是根据48 bit的以太网地址来确定目的接口的.设备驱动程序从不检查IP数据报中的目的IP地址.地址解析为这两种不同 ...

  2. Spring Data Redis配置项有多少(不列举具体,只提供找的方法)

    首先,要说明Spring Data Redis集成了很多款客户端,比如Jedis这些. 而如果在注入Bean时,我们一般是可以设置一些项的,比如hostName和port等,对于这些项一般的查找方式通 ...

  3. 禁用Bootstrap点击空白,modal自动关闭

    手动触发modal:       $('#myModal').modal(): 禁用点击空白,modal自动关闭:$('#myModal').modal({backdrop: 'static', ke ...

  4. Failed to execute 'toDataURL' on 'HTMLCanvasElement,在canvas.toDataURL()执行时候报错解决方案

    添加跨域条件   crossorigin="anonymous" [Redirect at origin 'http://xxx.xx.com' has been blocked ...

  5. 蓦然回首,Java 已经 24 岁了!

    01.蓦然 真没想到,Java 竟然 24 岁了(算是 90 后)! 提起 Java,印象最深刻的当然就是: class Cmower {  public static void main(Strin ...

  6. Angular团队公布路线图,并演示怎样与React Native集成

    本文来源于我在InfoQ中文站翻译的文章,原文地址是:http://www.infoq.com/cn/news/2015/06/angular-2-react-native-roadmap 前不久在旧 ...

  7. Centos 6.4 搭建LANMP一键安装版

    lanmp一键安装包是wdlinux官网2010年开始推出的lamp,lnmp,lnamp(apache,nginx,php,mysql,zend,eAccelerator,pureftpd)应用环境 ...

  8. 鸟哥的Linux私房菜-----12、学习使用Shell scripts

  9. vsCode 常用快捷键(mac 版)

    光标多行显示: commond+Alt+topArrow/downArrow 查找:commond+F 查找并按顺序切换下一个:commond+G 跳转到某一行: ctrl+G 输入行号跳转 跳转到某 ...

  10. linux 【第五篇】特殊权限及定时任务

    特殊权限 [root@VM_141_154_centos ~]# ls -ld /tmp drwxrwxrwt. 8 root root 4096 Apr 5 08:11 /tmp /tmp/ 公共目 ...