physics HDU
来源:互联网 发布:ecshop微商城源码 编辑:程序博客网 时间:2024/05/29 08:45
There are n balls on a smooth horizontal straight track. The track can be considered to be a number line. The balls can be considered to be particles with the same mass.
At the beginning, ball i is at position Xi. It has an initial velocity of Vi and is moving in direction
Given a constant
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
- Perfectly elastic collision : A perfectly elastic collision is defined as one in which there is no loss of kinetic energy in the collision.
Input
The first line contains an integer T, denoting the number of testcases.
For each testcase, the first line contains two integers
n lines follow. The i-th of them contains three integers
The next line contains an integer
q lines follow. Each line contains two integers
Output
For each query, print a single line containing the answer with accuracy of 3 decimal digits.
Sample Input
1
3 7
3 3 1
3 10 -1
2 7 1
3
2 3
1 2
3 3
Sample Output
6.083
4.796
7.141
也是比较水的题,题目大意是在一条直线上,有n个球,各自有一定的初速度,和方向(也就是说球与球之间会发生碰撞,为弹性碰撞),并且每个球的速度和加速度乘积为一个常数,那天我在的话就把这题给a了,唯一的难点可能就是积分吧,关于碰撞,只要把他当称两球相互穿过就可以了,如果只根据动量守恒定律那么速度是可以抵消的,但是在这里还得遵循能量守恒定律,没有能量损失,并且在质量相等的情况下,两者速度交换即可,因为球都是一样的,就当作相互穿过就好了
现在看积分:
移向:
得:
所以:
至于询问,只要从小到大排序即可,因为这个速度函数是递增的,经过相同时间,他们的大小关系不会改变
代码:
#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<vector>#include<queue>#include<cmath>#define N 100005#define mod 530600414using namespace std;int a[100005];int n,c;int main(){ int t; int m; int x,y; int time,k; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&c); for(int i=1;i<=n;i++) scanf("%d%d%d",a+i,&x,&y); sort(a+1,a+1+n); scanf("%d",&m); while(m--) { scanf("%d%d",&time,&k); printf("%.3lf\n",sqrt((double)a[k]*a[k]+2*c*(double)time)); } } return 0;}
- physics HDU
- hdu 5826 physics
- HDU 5826 physics
- hdu 5826 physics
- HDU 5826-physics
- hdu 5826 physics (物理+积分)
- HDU-5826-physics-数学推导
- HDU 5826 physics(物理)
- HDU 5826 physics 【弹性碰撞】
- An Easy Physics Problem HDU
- 物理题(physics,HDU 5826)
- physics
- physics
- physics
- hdu 5572 An Easy Physics Problem
- hdu 5572 An Easy Physics Problem
- HDU 5826 physics (数学推导)(规律)
- hdu 5826 physics (物理数学)
- time() localtime() gmtime()简介
- linux常用命令大全
- eclipse常用快捷键
- 爬虫记录(6)——爬虫实战:爬取知乎网站内容,保存到数据库,并导出到Excel
- 1009. 说反话 (20)
- physics HDU
- 重构第10章
- Java抽象类和抽象方法例子
- thinking in java——操作符
- 2017 ACM-ICPC 亚洲区(西安赛区)网络赛 F. Trig Function cos(nx)
- 【笔记】Excel函数
- 请问为什么用spring事务管理?
- maven spring springmvc mybatis搭建
- concurrent包的实现