hdu-5826 physics(数学)
题目链接:
physics
Time Limit: 6000/3000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
At the beginning, ball i is at position Xi. It has an initial velocity of Vi and is moving in direction Di.(Di∈−1,1)
Given a constant C. At any moment, ball its acceleration Ai and velocity Vi have the same direction, and magically satisfy the equation that Ai * Vi = C.
As there are multiple balls, they may collide with each other during the moving. We suppose all collisions are perfectly elastic collisions.
There are multiple queries. Each query consists of two integers t and k. our task is to find out the k-small velocity of all the balls t seconds after the beginning.
* Perfectly elastic collision : A perfectly elastic collision is defined as one in which there is no loss of kinetic energy in the collision.
For each testcase, the first line contains two integers n <= 10^5 and C <= 10^9.
n lines follow. The i-th of them contains three integers Vi, Xi, Di. Vi denotes the initial velocity of ball i. Xi denotes the initial position of ball i. Di denotes the direction ball i moves in.
The next line contains an integer q <= 10^5, denoting the number of queries.
q lines follow. Each line contains two integers t <= 10^9 and 1<=k<=n.
1<=Vi<=10^5,1<=Xi<=10^9
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>
#include <stack>
#include <map> using namespace std; #define For(i,j,n) for(int i=j;i<=n;i++)
#define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
F && (num=-num);
}
int stk[70], tp;
template<class T> inline void print(T p) {
if(!p) { puts("0"); return; }
while(p) stk[++ tp] = p%10, p/=10;
while(tp) putchar(stk[tp--] + '0');
putchar('\n');
} const LL mod=1e9+7;
const double PI=acos(-1.0);
const LL inf=1e18;
const int N=1e5+10;
const int maxn=5e3+4;
const double eps=1e-12; double v[N],pos[N],t,c;
int d[N],k,n; int main()
{
int T;
read(T);
while(T--)
{
read(n);
scanf("%lf",&c);
For(i,1,n)
{
scanf("%lf%lf%d",&v[i],&pos[i],&d[i]);
}
sort(v+1,v+n+1);
int q;
read(q);
while(q--)
{
scanf("%lf%d",&t,&k);
printf("%.3lf\n",sqrt(v[k]*v[k]+2*c*t));
}
}
return 0;
}
hdu-5826 physics(数学)的更多相关文章
- HDU 5826 physics(物理)
physics(物理) Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) D ...
- HDU 5826 physics (积分推导)
physics 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5826 Description There are n balls on a smoo ...
- hdu 5826 physics 物理题
physics 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5826 Description There are n balls on a smoo ...
- hdu 5826 physics (物理数学,积分)
physics Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Sub ...
- HDU 5826 physics
该问题和xi,di均无关,碰撞只会使得速度反向,大小不会变.因此只要计算速度. #pragma comment(linker, "/STACK:1024000000,1024000000&q ...
- hdu 5826 (物理) physics
题目:这里 题意:光滑的水平直线上有n个质量相等的小球,已知每个小球的初始位置,初始速度和方向,每个小球的每个时刻的加速度a都满足a*v=c,v是该时刻的速度,c是已知的 常数,小球之间的碰撞是完全碰 ...
- HDU 5673 Robot 数学
Robot 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5673 Description There is a robot on the origi ...
- HDU 5914 Triangle 数学找规律
Triangle 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Description Mr. Frog has n sticks, who ...
- HDU 2493 Timer 数学(二分+积分)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2493 题意:给你一个圆锥,水平放置,圆锥中心轴与地面平行,将圆锥装满水,在圆锥某一表面开一个小洞,流出来 ...
- HDU 1568 Fibonacci 数学= = 开篇
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1568 分析:一道数学题 找出斐波那契数列的通项公式,再利用对数的性质就可得到前几位的数 斐波那契通项公 ...
随机推荐
- vs2010+qt4编译出现error LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject等错误
1.当vs2010编译qt时会出现以下错误: 1>------ 已启动全部重新生成: 项目: MyDialog, 配置: Debug Win32 ------ 1>生 ...
- H5缓存机制学习记录
参考文章:http://mp.weixin.qq.com/s?__biz=MTEwNTM0ODI0MQ==&mid=404724239&idx=1&sn=e0a2887f9ff ...
- Linux相互排斥与同步应用(三):posix线程实现单个生产者和单个消费者模型
[版权声明:尊重原创.转载请保留出处:blog.csdn.net/shallnet 或 .../gentleliu.文章仅供学习交流,请勿用于商业用途] 在第一节说到了 ...
- Struts2实现input数据回显
/** 修改页面 */ public String editUI() { //准备回显得数据 Role role = roleService.getById(id); ...
- [转]浅谈Flash Socket通信安全沙箱
用过Flash socket的同学都知道,Flash socket通讯有安全沙箱问题.就是在Flash Player发起socket通信时,会向服务端获取安全策略,如果得不到服务端响应,flash将无 ...
- 如何在IntelliJ IDEA在线查看源码的API文档
https://blog.csdn.net/IFollowRivers/article/details/81604463
- TP 自动验证规则
#自动验证 protected $_validate=array( #参数最后代表1 表示必须验证,0表示当这个字段存在的时候验证 array('username','require','账号不能为空 ...
- 【NOI2015】【程序自己主动分析】【并查集+离散化】
Description 在实现程序自己主动分析的过程中,经常须要判定一些约束条件能否被同一时候满足. 考虑一个约束满足问题的简化版本号:如果x1,x2,x3,-代表程序中出现的变量.给定n个形如xi= ...
- Android-解决Fail to post notification on channel "null"的方法
原文:https://blog.csdn.net/weixin_40604111/article/details/78674563 在sdk版本为25或25之前想在notification中添加一个点 ...
- HDU 5343 MZL's Circle Zhou 后缀自动机+DP
MZL's Circle Zhou Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Othe ...