Codeforces Round#514 Div.2 翻车记
A:签到
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
#define N 100010
int n,l,m;
struct data{int x,y;
}a[N];
int main()
{
n=read(),l=read(),m=read();
for (int i=;i<=n;i++)
{
int x=read(),y=read();
a[i].x=x,a[i].y=x+y;
}
a[].x=a[].y=,a[n+].x=a[n+].y=l;
int ans=;
for (int i=;i<=n+;i++) ans+=(a[i].x-a[i-].y)/m;
cout<<ans;
return ;
}
B:只能对于一个八个方向都被要求染色的位置染色。染完之后看一下和所要求的图是否相同就行了。
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
#define N 1010
int n,m,a[N][N],b[N][N];
int main()
{
n=read(),m=read();
for (int i=;i<=n;i++)
{
for (int j=;j<=m;j++)
{
char c=getchar();
while (c!='#'&&c!='.') c=getchar();
if (c=='#') a[i][j]=;
else a[i][j]=;
}
}
for (int i=;i<=n;i++)
for (int j=;j<=m;j++)
if (a[i-][j]&&a[i][j-]&&a[i][j+]&&a[i+][j]&&a[i+][j+]&&a[i+][j-]&&a[i-][j+]&&a[i-][j-])
b[i-][j]=b[i][j-]=b[i][j+]=b[i+][j]=b[i+][j+]=b[i+][j-]=b[i-][j+]=b[i-][j-]=;
for (int i=;i<=n;i++)
for (int j=;j<=m;j++)
if (a[i][j]!=b[i][j]) {cout<<"NO";return ;}
cout<<"YES";
return ;
}
C:要求字典序最大也就要求gcd的变化尽量早出现。如果n>=4,最容易使gcd增大的方法肯定是删掉所有奇数。所以递归删除即可。
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
#define N 1000010
int n;
void print(int n,int s)
{
if (n==) {cout<<s;return;}
if (n==) {cout<<s<<' '<<(s<<);return;}
if (n==) {cout<<s<<' '<<s<<' '<<s*;return;}
for (int i=;i<=(n+)>>;i++) printf("%d ",s);
print(n>>,s*);
}
int main()
{
n=read();
print(n,);
return ;
}
D:二分圆半径,对于每个圆就可以求出它所要求的圆心所在区间,判断一下有没有交。然而不知道是写挂还是卡精度了,一个半小时都没搞出来,惨炸。
//wa on 5
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
#define N 100010
int n;
long double eps=1E-;
struct data{int x,y;
}a[N];
struct data2
{
long double x;int op;
bool operator <(const data2&a) const
{
return x<a.x;
}
}b[N];
bool check(long double k)
{
int t=;
for (int i=;i<=n;i++)
{
if (*k-a[i].y<) return ;
long double x=sqrt(a[i].y)*sqrt(*k-a[i].y);
b[++t].x=a[i].x-x,b[t].op=,b[++t].x=a[i].x+x+eps,b[t].op=-;
}
sort(b+,b+t+);
int cnt=;
for (int i=;i<=t;i++)
{
cnt+=b[i].op;
if (cnt==n) return ;
}
return ;
}
long double calc()
{
long double l=,r=2e18,ans=2e18;
while ((r-l)/((r+l)/)>eps)
{
long double mid=(l+r)/;bool flag=;
if (check(mid)) ans=mid,r=mid-eps;
else l=mid+eps;
}
return ans;
}
int main()
{
n=read();
long double flag1=,flag2=;
for (int i=;i<=n;i++)
{
a[i].x=read(),a[i].y=read();
if (a[i].y<) flag2=;
if (a[i].y>) flag1=;
}
if (flag1&&flag2) {cout<<-;return ;}
if (flag2) for (int i=;i<=n;i++) a[i].y=-a[i].y;
double ans=calc();printf("%.7lf",ans);
return ;
}
E:好像很多人过然而还并没有看。
result:rank 329 rating -14
Codeforces Round#514 Div.2 翻车记的更多相关文章
- Codeforces Round#500 Div.2 翻车记
A:签到 #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> # ...
- Codeforces Round#509 Div.2翻车记
A:签到 #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> # ...
- Educational Codeforces Round 56 Div. 2 翻车记
A:签到. B:仅当只有一种字符时无法构成非回文串. #include<iostream> #include<cstdio> #include<cmath> #in ...
- Educational Codeforces Round 55 Div. 2 翻车记
A:签到. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> ...
- Codeforces Round #524 Div. 2 翻车记
A:签到.room里有一个用for写的,hack了一发1e8 1,结果用了大概600+ms跑过去了.惨绝人寰. #include<iostream> #include<cstdio& ...
- Codeforces Round#516 Div.1 翻车记
A:开场懵逼.然后发现有人1min过,于是就sort了一下,于是就过了.正经证明的话,考虑回文串两端点一定是相同的,所以最多有Σcnti*(cnti+1)/2个,cnti为第i种字母出现次数.而sor ...
- Codeforces Round #517 Div. 1翻车记
A:真的懵逼了.冷静了半天之后决定二分一下答案,然后先a安排上尽量小的再贪心地一个个扩大.40min才过.这个做法非常怂的以代码复杂度和时间复杂度为代价换取了比较稳的正确性,事实上由于1~n可以组合出 ...
- Educational Codeforces Round 53 Div. 2翻车记
A:差点开场懵逼.只要有相邻两位不同就可以作为答案. #include<iostream> #include<cstdio> #include<cmath> #in ...
- Codeforces Round #394 (Div. 2) 颓废记
昨天晚上(今天凌晨),又忍不住去打CF.(本蒟弱到只能打Div.2)... 我觉得我可以用一个词概括我这次的CF: 呵呵 刚一开赛,我就codeforces访问失败.. 后来好不容易能上了,两三分钟才 ...
随机推荐
- 对PostgreSQL数据库的hstore类型建立GisT索引的实验
磨砺技术珠矶,践行数据之道,追求卓越价值回到上一级页面:PostgreSQL基础知识与基本操作索引页 回到顶级页面:PostgreSQL索引页[作者 高健@博客园 luckyjackgao@g ...
- HBase常用命令汇总——综述(一)
hbase(main):009:0> help HBase Shell, version 1.2.4, r67592f3d062743907f8c5ae00dbbe1ae4f69e5af, Tu ...
- SaltStack入门篇(一)之SaltStack部署
一.SaltStack概述 Salt,,一种全新的基础设施管理方式,部署轻松,在几分钟内可运行起来,扩展性好,很容易管理上万台服务器,速度够快,服务器之间秒级通讯. salt底层采用动态的连接总线, ...
- L012-linux系统文件属性知识深入详解小结
L012-linux系统文件属性知识深入详解小结 最近的学习重点不在这上面,所以更新的比较慢,再加上母亲住院,感情问题,一系列吧,愿快点度过这黑色的4月份,希望我能在5月份阳光起来,加油! 回归正题 ...
- ubuntu apt-xxx
1. apt-get install xxx 2. dpkg -l ; list software already installed. 3. apt-cache dumpavail ; print ...
- ffmpeg 踩坑实录 安装与视频切片(一)
这段时间一直在做一个关于视频处理的项目.其中有一块需要切片相关功能.于是采用了ffmpeg来完成相关需求. 第一,ffmpeg的安装. 首先下载官方包,我这里用的是ffmpeg-release-64b ...
- https双向认证网站搭建
新建网站 在搭建网站证书之前,我们先搭建好我们的网站 1.网站基本搭建 为我们的项目新建一个网站,按照如下的步骤来 1,打开IIS,右键单击网站弹出菜单,选择网站(如图1.1.1) 图1.1.1 2, ...
- 【bzm-Random CSV Data Set Config】 -jmeter - 文件中随机取参的方法,(插件自带)
文件中随机取参数的方法 Random CSV Data Set Config
- HBASE理论篇
1.Hbase是什么 HBase是一种构建在HDFS之上的分布式.面向列的存储系统.在需要实时读写.随机访问超大规模数据集时,可以使用HBase. 尽管已经有许多数据存储和访问的策略和实现方法,但事实 ...
- (python)剑指Offer 面试题51:数组中重复的数字
问题描述 在长度为n的数组中,所有的元素都是0到n-1的范围内. 数组中的某些数字是重复的,但不知道有几个重复的数字,也不知道重复了几次,请找出任意重复的数字. 例如,输入长度为7的数组{2,3,1, ...