HDU 5826 Physics

Source: Internet
Author: User

Water problem;

Test instructions: give you n ball, in one dimensional direction, each ball gives three quantities, respectively, the initial velocity v, the original coordinate x, the direction (1| | -1), each ball will move, the acceleration is a, meet the a*v=c,c known, may be a complete collision, ask the first T second K small speed is how much;

Idea: first saw A*v=c, immediately think of high school physics of constant power, car acceleration stage of the movement model, set m=1, then a*m*v=c=p; then use momentum theorem, p*t=1/2*m*v*v-1/2*m*v0*v0, can be obtained;

Code:

#include <bits/stdc++.h>using namespacestd;Const Long Longmaxn=1000000+ the;DoubleA[MAXN];intMain () {intT; CIN>>T;  while(t--)    {        intN; Long LongK; scanf ("%d%lld",&n,&k);  for(intI=0; i<n; i++)        {            Doublec,d; scanf ("%lf%f%f", &a[i+1],&c,&d); } sort (A+1, a+n+1); intm; scanf ("%d",&m); {             for(intI=0; i<n; i++)            {                intdd,cc; scanf ("%d%d",&dd,&cc); printf ("%.3f\n", sqrt (2*k*dd+a[cc]*A[CC])); }        }    }    return 0;}

HDU 5826 Physics

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.