考虑两个质量均为m,速度分别v1、v2的小球发生完全弹性碰撞的影响:

由动能守恒得:

$\frac{1}{2}mv_1^2+\frac{1}{2}mv_2^2=\frac{1}{2}mv_1'^2+\frac{1}{2}mv_2'^2$
$v_1^2+v_2^2=v_1'^2+v_2'^2$

由动量守恒得:

$mv_1+mv_2=mv_1'+mv_2'$
$v_1+v_2=v_1'+v_2'$
$v_1^2+v_2^2+2v_1v_2=v_1'^2+v_2'^2+2v_1'v_2'$

所以

$v_1v_2=v_1'v_2'$
$v_1'=v_2$
$v_2'=v_1$

结论:两个质量相同的小球发生完全弹性碰撞后交换速度。

由于询问的是第k小的速率,并没有要求是哪个小球,所以可以视为小球并没有发生碰撞,而是直接按原速度穿过去,所以直接计算出每个小球在t时刻的速度就可以了。

现在考虑怎么求速度:

每一时刻加速度$av=C$

而加速度可以看做是速度函数的导数,

设$f(x)$为x时刻的速度,$f(0)=v$,$f(x)f'(x)=C$

解得

$f(x)=\sqrt{2Cx+v^2}$

因为在t时刻,影响最终速度排名的只有初速度v,所以只需要用数据结构维护v的顺序就可以了。

时间复杂度$O((n+q)\log n)$

#include<cstdio>
#include<cmath>
#define N 200010
using namespace std;
typedef long long ll;
const double A=0.8;
int n,c,x,y,z,size[N],son[N][2],val[N],f[N],tot,root,data[N],id[N],cnt;
int ins(int x,int p){
size[x]++;
int b=p>=val[x];
if(!son[x][b]){
son[x][b]=++tot;f[tot]=x;size[tot]=1;
val[tot]=p;
return tot;
}else return ins(son[x][b],p);
}
void dfs(int x){
if(son[x][0])dfs(son[x][0]);
data[++cnt]=val[x];id[cnt]=x;
if(son[x][1])dfs(son[x][1]);
}
int build(int fa,int l,int r){
int mid=(l+r)>>1,x=id[mid];
f[x]=fa;son[x][0]=son[x][1]=0;size[x]=1;
val[x]=data[mid];
if(l==r)return x;
if(l<mid)size[x]+=size[son[x][0]=build(x,l,mid-1)];
if(r>mid)size[x]+=size[son[x][1]=build(x,mid+1,r)];
return x;
}
inline int rebuild(int x){
cnt=0;dfs(x);return build(f[x],1,cnt);
}
inline void insert(int p){
if(!root){root=tot=size[1]=1;val[1]=p;return;}
int x=ins(root,p);
int deep=0;int z=x;while(f[z])z=f[z],deep++;
if(deep<log(tot)/log(1/A))return;
while((double)size[son[x][0]]<A*size[x]&&(double)size[son[x][1]]<A*size[x])x=f[x];
if(!x)return;
if(x==root){root=rebuild(x);return;}
int y=f[x],b=son[y][1]==x,now=rebuild(x);
son[y][b]=now;
}
inline int kth(int k){
int x=root,sum;
while(1){
sum=size[son[x][0]]+1;
if(k==sum)return val[x];
if(k<sum)x=son[x][0];else k-=sum,x=son[x][1];
}
}
inline void read(int&a){
char c;bool f=0;a=0;
while(!((((c=getchar())>='0')&&(c<='9'))||(c=='-')));
if(c!='-')a=c-'0';else f=1;
while(((c=getchar())>='0')&&(c<='9'))(a*=10)+=c-'0';
if(f)a=-a;
}
int main(){
read(n);read(c);
while(n--)read(x),read(y),read(z),insert(x);
read(n);
while(n--){
read(x);
if(x)read(y),read(z),z=kth(z),printf("%.3f\n",sqrt(2*(ll)c*(ll)y+(ll)z*(ll)z));
else read(x),read(y),read(y),insert(x);
}
return 0;
}

  

BZOJ3570 : DZY Loves Physics I的更多相关文章

  1. 【权值分块】bzoj3570 DZY Loves Physics I

    以下部分来自:http://www.cnblogs.com/zhuohan123/p/3726306.html 此证明有误. DZY系列. 这题首先是几个性质: 1.所有球质量相同,碰撞直接交换速度, ...

  2. CF 444C DZY Loves Physics(图论结论题)

    题目链接: 传送门 DZY Loves Chemistry time limit per test1 second     memory limit per test256 megabytes Des ...

  3. cf444A DZY Loves Physics

    A. DZY Loves Physics time limit per test 1 second memory limit per test 256 megabytes input standard ...

  4. Codeforces Round #254 (Div. 1) A. DZY Loves Physics 智力题

    A. DZY Loves Physics 题目连接: http://codeforces.com/contest/444/problem/A Description DZY loves Physics ...

  5. CodeForces 444C. DZY Loves Physics(枚举+水题)

    转载请注明出处:http://blog.csdn.net/u012860063/article/details/37509207 题目链接:http://codeforces.com/contest/ ...

  6. Codeforces 444A DZY Loves Physics(图论)

    题目链接:Codeforces 444A DZY Loves Physics 题目大意:给出一张图,图中的每一个节点,每条边都有一个权值.如今有从中挑出一张子图,要求子图联通,而且被选中的随意两点.假 ...

  7. 【Codeforces 444A】DZY Loves Physics

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 两个点的子图他们的"密度"是比所有联通生成子图都要大的 "只要胆子大,遇到什么问题都不怕!" [代码] ...

  8. CF444A DZY Loves Physics【结论】

    题目传送门 话说这道题不分析样例实在是太亏了...结论题啊... 但是话说回来不知道它是结论题的时候会不会想到猜结论呢...毕竟样例一.二都有些特殊. 观察样例发现选中的子图都只有一条边. 于是猜只有 ...

  9. @codeforces - 444A@ DZY Loves Physics

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定一个 n 点 m 边的图,边有边权,点有点权. 找到一个连通 ...

随机推荐

  1. js检测是否安装了flash插件

    function flashChecker() { var hasFlash = 0; //是否安装了flash var flashVersion = 0; //flash版本 var isIE = ...

  2. Coursera台大机器学习课程笔记8 -- Linear Regression

    之前一直在讲机器为什么能够学习,从这节课开始讲一些基本的机器学习算法,也就是机器如何学习. 这节课讲的是线性回归,从使Ein最小化出发来,介绍了 Hat Matrix,要理解其中的几何意义.最后对比了 ...

  3. Centos 7 安装LAMP环境

    一.安装Centos 官网下载Centos 7刻录成光盘后安装 二.安装apache yum install httpd #根据提示,输入Y安装即可成功安装 systemctl start httpd ...

  4. 【持续集成】使用Jenkins实现多平台并行集成

    使用Jenkins实现多平台并行集成 二月 15, 2012 暂无评论 我们的后端C应用都是支持跨平台的,至少目前在Linux和Solaris上运行是没有问题的,这样一来我们在配置持续集成环境时就要考 ...

  5. 《ASP.NET MVC4 WEB编程》学习笔记------RenderBody,RenderPage,RenderSection

    ASP.NET MVC 3 已经正式发布了,现在估计许多人都在拼命学,我也不能例外,刚刚看到了一篇文章,介绍了三个非常有用的方法:RenderBody,RenderPage和RenderSection ...

  6. 使用__declspec(export)导出C++类到DLL

    使用举例: // File: SimpleDLLClass.h#ifdef SIMPLEDLL_EXPORT //在DLL工程属性-c/c++-预处理器-预处理器定义中添加此宏定义#define DL ...

  7. July 15th, Week 29th Friday, 2016

    A book is a gift that you can open again and again. 书是你可以一次又一次打开的礼物. Some gifts are born with you, a ...

  8. sysctl命令详解

    个人一般sysctl -p 或sysctl -a比较多使用 sysctl配置与显示在/proc/sys目录中的内核参数.可以用sysctl来设置或重新设置联网功能,如IP转发.IP碎片去除以及源路由检 ...

  9. 手机 无法转移到SD卡 Andriod 导出应用程序

    今天下载了一个应用Meridian,因为是直接从google商店里面装的,因此无法找到SDK,需要从新找到导出方式: 豌豆荚==> 软件和游戏管理==>输入Meridian搜素==> ...

  10. ImageView中XML属性src和background的区别

    background会根据ImageView组件给定的长宽进行拉伸,而src就存放的是原图的大小,不会进行拉伸. src是图片内容(前景),bg是背景,可以同时使用. 此外:scaleType只对sr ...