• 原题如下:

    Physics Experiment
    Time Limit: 1000MS   Memory Limit: 65536K
    Total Submissions: 3583   Accepted: 1275   Special Judge

    Description

    Simon is doing a physics experiment with N identical balls with the same radius of R centimeters. Before the experiment, all N balls are fastened within a vertical tube one by one and the lowest point of the lowest ball is H meters above the ground. At beginning of the experiment, (at second 0), the first ball is released and falls down due to the gravity. After that, the balls are released one by one in every second until all balls have been released. When a ball hits the ground, it will bounce back with the same speed as it hits the ground. When two balls hit each other, they with exchange their velocities (both speed and direction).

    Simon wants to know where are the N balls after T seconds. Can you help him?

    In this problem, you can assume that the gravity is constant: g = 10 m/s2.

    Input

    The first line of the input contains one integer C (C ≤ 20) indicating the number of test cases. Each of the following lines contains four integers NHRT.
    1≤ N ≤ 100.
    1≤ H ≤ 10000
    1≤ R ≤ 100
    1≤ T ≤ 10000

    Output

    For each test case, your program should output N real numbers indicating the height in meters of the lowest point of each ball separated by a single space in a single line. Each number should be rounded to 2 digit after the decimal point.

    Sample Input

    2
    1 10 10 100
    2 10 10 100

    Sample Output

    4.95
    4.95 10.20
  • 题解:一个球的情形很简单。多个球的情形先考虑R=0,模仿热身题(POJ 1852),在那道题中两只蚂蚁相遇后折返我们将其看作不折返而是擦身而过继续走下去,这里我们就可以无视碰撞,视为直接互相穿过继续运动,由于在有碰撞时,球的相对顺序是不会变得的,所以忽略碰撞,将计算得到的坐标进行排序后,就能直到每个球的最终位置。然后我们再考虑R>0的情形,对于从下方开始的第i个球,在按照R=0计算的结果上加上2Ri就好了。
  • 代码:
     #include <cstdio>
    #include <cctype>
    #include <algorithm>
    #include <cmath>
    #include <cstring>
    #define number s-'0' using namespace std; const int MAX_N=;
    const double g=10.0;
    int K,N,H,R,T;
    double y[MAX_N]; void read(int &x){
    char s;
    x=;
    bool flag=;
    while(!isdigit(s=getchar()))
    (s=='-')&&(flag=true);
    for(x=number;isdigit(s=getchar());x=x*+number);
    (flag)&&(x=-x);
    } void write(int x)
    {
    if(x<)
    {
    putchar('-');
    x=-x;
    }
    if(x>)
    write(x/);
    putchar(x%+'');
    } double calc(int); int main()
    {
    read(K);
    while (K>)
    {
    read(N);read(H);read(R);read(T);
    for (int i=; i<N; i++)
    {
    y[i]=calc(T-i);
    }
    sort(y,y+N);
    for (int i=; i<N; i++)
    printf("%.2f%c", y[i]+*R*i/100.0, i+==N? '\n': ' ');
    K--;
    }
    } double calc(int T)
    {
    if (T<=) return H;
    double t=sqrt(*H/g);
    int k=(int)(T/t);
    if (k%==)
    {
    double d=T-k*t;
    return H-g*d*d/;
    }
    else
    {
    double d=k*t+t-T;
    return H-g*d*d/;
    }
    }

Physics Experiment(POJ 3684)的更多相关文章

  1. POJ 3684 Physics Experiment(弹性碰撞)

    Physics Experiment Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2936   Accepted: 104 ...

  2. poj 3684 Physics Experiment 弹性碰撞

    Physics Experiment Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1489   Accepted: 509 ...

  3. poj 3684 Physics Experiment(数学,物理)

    Description Simon ), the first ball is released and falls down due to the gravity. After that, the b ...

  4. poj 3684

    Physics Experiment Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 784   Accepted: 266 ...

  5. [POJ3684]Physics Experiment

      Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1363   Accepted: 476   Special Judge ...

  6. POJ3684 Physics Experiment 【物理】

    Physics Experiment Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1031   Accepted: 365 ...

  7. 弹性碰撞 poj 3684

    Simon is doing a physics experiment with N identical balls with the same radius of R centimeters. Be ...

  8. POJ 3684 Physics Experiment

    和蚂蚁问题类似. #include<cstdio> #include<cstring> #include<cmath> #include<vector> ...

  9. Greedy:Physics Experiment(弹性碰撞模型)(POJ 3848)

    物理实验 题目大意:有一个与地面垂直的管子,管口与地面相距H,管子里面有很多弹性球,从t=0时,第一个球从管口求开始下落,然后每1s就会又有球从球当前位置开始下落,球碰到地面原速返回,球与球之间相碰会 ...

随机推荐

  1. Shiro+SpringBoot认证

    该博客以Web为基础 一.引入依赖 shiro-all包含shiro所有的包.shiro-core是核心包.shiro-web是与web整合.shiro-spring是与spring整合.shiro- ...

  2. 题解 洛谷 P1553

    字符串入门题,读入一行字符,先将第一个数读入翻转,读入下一个字符(如果没有则退出),再将下一个数读入翻转 #include<iostream> #include<cstdio> ...

  3. Android Studio gridview 控件使用自定义Adapter, 九宫格items自适应全屏显示

    先看效果图,类似于支付宝首页的效果.由于九宫格显示的帖子网上已经很多,但是像这样九宫格全屏显示的例子还不是太多.本实例的需求是九宫格全屏显示,每个子view的高度是根据全屏高度三等分之后自适应高度,每 ...

  4. IDEA中列编辑

    快捷键 :Alt+Shift+insert,也可以按住Alt+Shift时,点击要编辑部分

  5. Jmeter 常用函数(2)- 详解 __RandomDate

    如果你想查看更多 Jmeter 常用函数可以在这篇文章找找哦 https://www.cnblogs.com/poloyy/p/13291704.html 作用 产生一个随机日期 语法格式 ${__R ...

  6. 第5章 JDBC/ODBC服务器

    第5章 JDBC/ODBC服务器 Spark SQL也提供JDBC连接支持,这对于让商业智能(BI)工具连接到Spark集群上以 及在多用户间共享一个集群的场景都非常有用.JDBC 服务器作为一个独立 ...

  7. python中eval, exec, execfile,和compile

    eval(str [,globals [,locals ]])函数将字符串str当成有效Python表达式来求值,并返回计算结果. 同样地, exec语句将字符串str当成有效Python代码来执行. ...

  8. 实用的git log用法

    git log可以很方便地查看日志,可以根据自己需要,将日志按照特定格式显示,或者输出某种格式. 最原始的输出样式: $ git log commit ca82a6dff817ec66f4434200 ...

  9. 自动部署Asp.Net Core到Docker

    原文链接:个人博客:自动部署Asp.Net Core至Docker 本文简介 最近在开发一个管理系统,代码框架是用的前后台分离的方式 后台使用的是Asp.Net Core平台,开发所有业务,向前台提供 ...

  10. 两台Windows Server 2012 R2数据库同步

    文件服务器/备库(192.168.0.1) 数据库服务器/备份文件服务器(192.168.0.2) 数据库实时同步 一.在主数据库服务器里,同样打开隐藏文件,找到C:\ProgramData\MySQ ...