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;
}
最新文章
- mac brew install redis 报错
- 33条C#和.NET经典面试题目及答案
- ActiveMQ_监听器(四)
- Win7 64位 VS2013环境编译boost1_58_0
- hdu4825 字典树 XOR
- 【风马一族_Android】 图能
- python 发邮件 utf-8
- iOS-NSAttributedString自定义文字变色
- SGU 548 Dragons and Princesses
- java 重写的学习
- java复习要点(一)------- java语言的特点、java的工作原理、配置环境变量、java命令的使用
- 三、Spring Boot 多数据源配置
- C#使用Socket实现一个socket服务器与多个socket客户端通信
- git 撤销没有提交的变化
- 为何学习matplotlib-【老鱼学matplotlib】
- SQL中内连接和外连接的区别
- Angular4 组件间通讯
- Unity3D热更新之LuaFramework篇[03]--prefab加载和Button事件
- Hive| DDL| DML
- 面试汇总——说一下CSS盒模型
热门文章
- nodejs读取配置文件
- 有一个长为n的数组A,求满足0≤a≤b<;n的A[b]-A[a]的最大值。 给定数组A及它的大小n,请返回最大差值。
- 果园里有一堆苹果,一共n头(n大于1小于9)熊来分,第一头为小东,它把苹果均分n份后,多出了一个,它扔掉了这一个,拿走了自己的一份苹果,接着第二头熊重复这一过程,即先均分n份,扔掉一个然后拿走一份,以此类推直到最后一头熊都是这样(最后一头熊扔掉后可以拿走0个,也算是n份均分)。问最初这堆苹果最少有多少个。
- 精彩回顾 HUAWEI HiAI 亮相华为北研所
- Selenium3 Python3 Web自动化测试从基础到项目实战之一启动不同的浏览器及配置
- Linux下Kafka单机安装配置方法
- CentOS6.5安装MySQL5.6 过程记录
- Django的标准库django.contrib包介绍(转)
- notHere 对框架解决方案的框架预期处理
- python cookbook第三版学习笔记八:解析码流