Codeforces Round #280 (Div. 2)
B. Vanya and Lanterns
题意:给出n个路灯,街道的长度,求出路灯的最小照射半径,使得整条街道都被照亮。
求出起点到第一盏灯的距离---n盏灯之间的距离/2---最后一盏灯到街尾的距离,找出这些值里面的最大值。
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include <cmath> 5 #include<algorithm> 6 using namespace std; 7 8 typedef long long LL; 9 int a[10005],b[10005]; 10 11 int main() 12 { 13 int n,l,i,x,y; 14 double d; 15 cin>>n>>l; 16 for(i=1;i<=n;i++) cin>>a[i]; 17 sort(a+1,a+n+1); 18 int maxd=-1; 19 for(i=1;i<n;i++) 20 { 21 b[i]=a[i+1]-a[i]; 22 maxd=max(maxd,b[i]); 23 } 24 x=a[1]-0; 25 y=l-a[n]; 26 // printf("x=%d\n",x); 27 // printf("y=%d\n",y); 28 // printf("maxd=%d\n",maxd); 29 if(2*x>maxd&&x>=y) printf("%.7lf\n",x*1.0); 30 else if(y>=x&&2*y>maxd) printf("%.7lf\n",y*1.0); 31 32 else printf("%.7lf\n",maxd*0.5); 33 34 }
View Code
C. Vanya and Exams
题意:给出n场考试,每场考试只能考到的最高分r,平均分 再给出现在每场考试的成绩a[i],提高一分需要做的试卷b[i],问至少需要做多少张试卷才能每科都达到平均分
先按照b[i]从小到大排序,再算出需要做的试卷数量,模拟做试卷
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include <cmath> 5 #include<algorithm> 6 using namespace std; 7 8 typedef long long LL; 9 struct node{ 10 int x,y; 11 } a[100005]; 12 13 int cmp(node n1,node n2){ 14 if(n1.y!=n2.y) return n1.y<n2.y; 15 return n1.x<n2.x; 16 } 17 18 int main() 19 { 20 LL tmp=0,sum=0,ans=0,c,i, n,r,avg; 21 cin>>n>>r>>avg; 22 for(i=1;i<=n;i++) { 23 cin>>a[i].x>>a[i].y; 24 sum+=a[i].x; 25 } 26 sort(a+1,a+n+1,cmp); 27 ans=n*avg-sum; 28 29 // for(i=1;i<=n;i++) 30 // { 31 // printf("%d %d\n",a[i].x,a[i].y); 32 // } 33 // printf("ans=%d\n\n",ans); 34 if(ans<=0) printf("0\n"); 35 else 36 { 37 for(i=1;i<=n;i++){ 38 if(ans<=(r-a[i].x)){ 39 tmp+=ans*a[i].y; 40 c=ans; 41 } 42 else{ 43 tmp+=(r-a[i].x)*a[i].y; 44 c=r-a[i].x; 45 } 46 ans=ans-c; 47 if(ans<=0) break; 48 } 49 printf("%I64d\n",tmp); 50 } 51 }
View Code
D. Vanya and Computer Game
题意:给出n只怪兽,vanya打怪的频率为x次每秒,给怪兽的伤害是1/x vova打怪的频率为y次每秒,给怪的伤害是1/y 再给出每只怪兽最多被伤害的次数 问第i只怪兽是被谁打败的
看的题解= =
可以转化为vanya每y秒伤害一次怪兽,vova每x秒伤害一次怪兽 再在时间轴上查找被攻击的次数,肯定是能被x或者y或者两者都整除的
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include <cmath> 5 #include<algorithm> 6 using namespace std; 7 8 typedef long long LL; 9 LL i,n,x,y,l,r,m,atk,a; 10 11 void bsearch(LL a) 12 { 13 l=1,r=1e15; 14 while(l<r){ 15 m=(l+r)/2; 16 atk=m/y+m/x; 17 if(atk>=a) r=m; 18 else l=m+1; 19 } 20 if(l%x==0&&l%y==0) printf("Both\n"); 21 else if(l%x==0) printf("Vova\n"); 22 else printf("Vanya\n"); 23 } 24 25 int main() 26 { 27 cin>>n>>x>>y; 28 for(i=1;i<=n;i++){ 29 cin>>a; 30 bsearch(a); 31 } 32 return 0; 33 }
View Code
话说这是做的第一次 cf诶----当时做A的时候发现是一个公式= =1+(1+2)+(1+2+3)---记得等于6分之多少来着---百度到之后,交上去= =居然过啦(好激动)
加油啊- ---- go--go--go
转载于:https://www.cnblogs.com/wuyuewoniu/p/4313646.html
Codeforces Round #280 (Div. 2)相关推荐
- Codeforces Round #280 (Div. 2) D. Vanya and Computer Game 二分
D. Vanya and Computer Game Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...
- CodeForces Round #280 (Div.2)
A. Vanya and Cubes 题意: 给你n个小方块,现在要搭一个金字塔,金字塔的第i层需要 个小方块,问这n个方块最多搭几层金字塔. 分析: 根据求和公式,有,按照规律直接加就行,直到超过n ...
- Educational Codeforces Round 112(Div.2) ABC题解
D题好像可以做一做,挖个坑以后做好了来填(doge Educational Codeforces Round 112(Div.2) 题目列表 1.A 2.B 3.C 1.A 原题链接 题目大意 有三种 ...
- Codeforces Round #506 (Div. 3)
Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...
- Codeforces Round #563 (Div. 2)/CF1174
Codeforces Round #563 (Div. 2)/CF1174 CF1174A Ehab Fails to Be Thanos 其实就是要\(\sum\limits_{i=1}^n a_i ...
- 构造 Codeforces Round #302 (Div. 2) B Sea and Islands
题目传送门 1 /* 2 题意:在n^n的海洋里是否有k块陆地 3 构造算法:按奇偶性来判断,k小于等于所有点数的一半,交叉输出L/S 4 输出完k个L后,之后全部输出S:) 5 5 10 的例子可以 ...
- Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解(每日训练 Day.16 )
整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解 比赛链接:h ...
- Codeforces Round #712 Div.2(A ~ F) 超高质量题解(每日训练 Day.15 )
整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #712 Div.2(A ~ F) 题解 比赛链接:https:// ...
- Codeforces Round #701 (Div. 2) A ~ F ,6题全,超高质量良心题解【每日亿题】2021/2/13
整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 A - Add and Divide B - Replace and Keep Sorted C ...
最新文章
- spring boot 通过Maven + tomcat 自动化部署
- 【VirtualBox】VirtualBox使用现有的虚拟盘文件(如VHD)创建虚拟机时,报错:打开虚拟硬盘失败,“UUID already exist”的解决方法
- python自学步骤-Python入门深度学习完整指南
- Android application捕获崩溃异常
- 快速排序算法javascript实现
- 【Android开发】我的第一个安卓程序
- ai不同形状的拼版插件_AI矩形/异型自动排料插件AINester 16.0(支持Illustrator CC 2015/2017)...
- PAT_B_1060_Java(25分)
- 某个应用导致html文件,某个应用导致你的默认浏览器设置出现问题(补丁又闯祸:Windows 10默认应用被重置 附解决方法)...
- 这几个动态规划的问题,面试官就爱问
- 数据源改成mysql_flowable流程war修改成数据源为mysql
- 库克谈iPhone 12供应紧张问题;2020中国互联网百强名单:阿里、腾讯、美团分列前三;Dgraph新版发布|极客头条
- How do you simple use git repository
- flex blazeds java spring_Flex+Java+Spring+BlazeDS 配置篇说明
- 频率学派(Frequentists) 贝叶斯学派(Bayesians)
- Oracle基础 10 表 table
- 2022黑马程序员-前端学习第一阶段(Day02-HTML基础)
- ps抠图-基础篇(三)
- java微信获取临时素材_java实现微信获取/下载临时素材
- 最大熵阈值python_李航统计学习方法(六)----逻辑斯谛回归与最大熵模型
热门文章
- DEKR 解构式关键点回归(一):算法思想与原理
- 网络编程(一)基础知识
- 国土空间适宜性评价与承载力评价之间的逻辑关系是什么?
- linux 监控键盘,如何在Linux中使用“LogKeys”监视键盘敲键
- 中lisp文件_关于 Emacs 中的变量你需要知道的事情 | Linux 中国
- linux 获取文件父目录权限,使用setfacl实现子目录继承父目录权限
- 使用Navicat计划任务备份数据库
- 十二、安装redis3.2
- python字符串常用函数-大小写,删除空格,字符串切片
- codeforces 536a//Tavas and Karafs// Codeforces Round #299(Div. 1)