【BZOJ】【P3570】【DZY Loves Physics I】【题解】【树状数组】
来源:互联网 发布:学编程好找工作吗 编辑:程序博客网 时间:2024/06/05 14:11
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3570
ans=sqrt(2CT+v0^2)
树状数组维护v0 k值
Code:
#include<bits/stdc++.h>#define lowbit(x) (x&-x)using namespace std;const int maxn=1<<17;int n,m,C;int getint(){int res=0;char c=getchar();while(!isdigit(c))c=getchar();while(isdigit(c))res=res*10+c-'0',c=getchar();return res;}int d[maxn];void updata(int x,int f){while(x<maxn)d[x]+=f,x+=lowbit(x);}int kth(int k){ int l=0,r=maxn,cur=0; while(l<r){ int mid=(l+r)/2;cur+=d[mid]; if(cur>=k)r=mid,cur-=d[mid]; else l=mid+1; }return l;}int main(){n=getint();C=getint();for(int i=1;i<=n;i++){int x=getint();updata(x,1);getint();getint();}m=getint();while(m--){int op=getint(),x=getint();if(op==0){getint();getint();updata(x,1);}else{int y=getint();int z=kth(y);printf("%.3lf\n",sqrt((double)2*C*x+(double)z*z));}}return 0;}
0 0
- 【BZOJ】【P3570】【DZY Loves Physics I】【题解】【树状数组】
- cf444A DZY Loves Physics
- dzy loves physics
- 【code force444A】DZY Loves Physics
- [bzoj 3563&3569]DZY Loves Chinese I&II
- HDU 5196 DZY Loves Inversions(树状数组,二分)
- Codeforces 444A. DZY Loves Physics
- Codeforces 444A DZY Loves Physics(图论)
- Codeforces 444A DZY Loves Physics
- CodeForces 444A DZY Loves Physics
- Codeforces Round 445 C. DZY Loves Physics
- Codeforces 444A DZY Loves Physics
- codeforces H. DZY Loves Physics(巧证)
- 【Codeforces 444A DZY Loves Physics】
- CodeForces 445C DZY Loves Physics
- CodeForces 444C. DZY Loves Physics
- codeforces - 444c DZY Loves Physics【水】
- Codeforces】-445C-DZY Loves Physics
- 日语学习之沪江N4基础 20141123
- 从proc目录下的zoneinfo认识Linux内存管理
- 全面理解面向对象的 JavaScript
- What’s The Difference Between A Codec, Container And Video Format?
- 基于MFC和OpenCV的图像处理小软件
- 【BZOJ】【P3570】【DZY Loves Physics I】【题解】【树状数组】
- 数组中超过出现次数一半的数字 【微软面试100题 第七十四题】
- netty学习网站
- Delphi XE7实现的任意位置弹出菜单
- boa cgi实现ajax
- Android笔记008_关于数据库的前滚和回滚的区别
- Quartz2D之贝塞尔涂鸦板(UIBezierPath)
- (软工视频总结三)数据流程图
- MongoDB学习笔记