3570:dzy Loves Physics I time limit:10 Sec Memory limit:256 MB
submit:101 solved:64
[Submit] [Status] DescriptionbackgroundAs we all know, Dzy is a university bully, proficient in physics. One day, merchant take a physics topic to ask Dzy,dzy soon on the second this problem, but lazy forget, let you to solve it.
Title DescriptionNow there is an infinitely long smooth track on the horizontal plane, with n Balls (volume omitted), and the mass of each ball is the same. Now these balls begin to move under some magical force. Given a constant C, each ball at any moment of speed V and acceleration A are satisfied a*v=c.Merchant also stipulates that at any given moment, the acceleration a of each ball is the same as the Velocity v.
because of the existence of multiple balls, in motion, there may be collisions between the small balls, where the collision between the ball is assumed to be a fully elastic collision. Merchant will also give you a constant C, the starting position of each ball, the direction of movement, and the initial velocity VI.Merchant's query is this: give you an integer t,k, let you ask the current system, let the ball start to move the T moment, the rate of the small ball of the speed of the number. note that after each inquiry, the ball returns to its original position.
of course, to examine your ability to improvise, merchant will occasionally add new balls when asking questions.
InputThe first line consists of two positive integer n,c.next n rows, each row contains three integers vi,xi,diVI represents the rate of the first ballXi represents the initial position of the first ball (you can imagine that the track is a axis)di represents the initial motion direction of the first ball, where 1 represents the positive direction, and 1 indicates the opposite direction. the next line of Q represents the number of operationsNext Q Line, the first number is the type of operation TP0 VJ Xj DJ represents Merchant added an initial speed Vj, position Xj, movement direction Dj's Ball1 T K represents a merchant
Outputfor each query, the output line contains a real number, which represents the answer. Retains 3 decimal places.
Data Rangen,m<=10^5 vi<=10^5 | Xi|<=10^9 0<c<=10^9 0<=t<=10^5ensure data is valid
Sample Input3 10
1 2 1
3 4 1
6 5 1
3
1 5 1
0 8-5-1
1 8 2
Sample Output10.050
13.000
HINT
N,q<=10^5 vi<=10^5 | Xi|<=10^9 0<c<=10^9 0<=t<=10^5
Source
by Acrossthesky
Exercises
After...... Derivation, and then we find that just ask for the K of V small on the line ...
Chairman Tree, Balance tree? Overqualified.
Then using the weighted segment tree is very easy to find in the LGN time of the K small
But we found that the tree-like array can actually ...
The principle of self-brain repair it ...
Code:
1#include <cstdio>2 3#include <cstdlib>4 5#include <cmath>6 7#include <cstring>8 9#include <algorithm>Ten One#include <iostream> A -#include <vector> - the#include <map> - -#include <Set> - +#include <queue> - +#include <string> A at #defineINF 1000000000 - - #defineMAXN (1<<17) - - #defineMAXM 20000000+5 - in #defineEPS 1e-10 - to #definell Long Long + - #definePA pair<int,int> the * #defineFor0 (i,n) for (int i=0;i<= (n); i++) $ Panax Notoginseng #defineFor1 (i,n) for (int i=1;i<= (n); i++) - the #defineFor2 (i,x,y) for (int i= (x); i<= (y); i++) + A #defineFor3 (i,x,y) for (int i= (x); i>= (y); i--) the + #defineMoD 1000000007 - $ using namespacestd; $ -InlineintRead () - the { - Wuyi intx=0, f=1;CharCh=GetChar (); the - while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();} Wu - while(ch>='0'&&ch<='9') {x=Ten*x+ch-'0'; ch=GetChar ();} About $ returnx*F; - - } - intn,q,c,s[maxn+1]; AInlinevoidAddintx) { for(;x<=maxn;x+=x& (-X)) s[x]++;} + the intMain () - $ { the theFreopen ("Input.txt","R", stdin); the theFreopen ("output.txt","W", stdout); -N=read (); c=read (); in while(n--) Add (Read ()), read (), read (); theq=read (); the while(q--) About { the intCh=read (); the if(!ch) Add (read ()), read (), read (); the Else + { - intL=0, R=maxn,t=read (), K=read (), sum=0; the while(l<R)Bayi { the intMid= (l+r) >>1; sum+=S[mid]; the //cout<<l<< ' <<mid<< ' <<r<< ' <<sum<< ' <<k<<endl; - if(sum>=k) R=mid,sum-=s[mid];ElseL=mid+1; - } theprintf"%.3f\n",(Double) sqrt (LL)2*c*t+ (LL) l*l)); the } the } the - return 0; the the}
View Code
Bzoj3570:dzy Loves Physics I