BestCoder Round #14 A题 Harry And Physical Teacher

Harry And Physical Teacher


Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1205    Accepted Submission(s): 386


Problem Description
As we all know, Harry Porter learns magic at Hogwarts School. However, learning magical knowledge alone is insufficient to become a great magician. Sometimes, Harry also has to gain knowledge from other certain subjects, such as language, mathematics, English, and even algorithm. Today, Harry's physical teacher set him a difficult problem: if a small ball moving with a speed V 0   made a completely elastic collision with a car moving towards the same direction with a speed V(V<V 0 )  , and the car far outweighs the ball, what was the speed of the small ball after the collision? This problem was so difficult that Harry hasn't figure out how to solve it. Therefore, he asks you for help. Could you do him this favor?
 
Input
They are several test cases, you should process to the end of file. There are two integers V  and V 0   for each test case. All the integers are 32-bit signed non-negative integers.
 
Output
For each test case, just output one line that contains an integer indicate the speed of the small ball after the collision.
 
Sample Input
0 10
 
Sample Output
-10


这是一道物理题,完全弹性碰撞,用到动量守恒定律
联立动能守恒,动量守恒方程。这里注意一个特殊的条件,车的质量远大于小球,那么结合下实际情况,一个质量很小的物体撞质量很大的物体,大的物体的速度是不会发生变化的。有了这个条件,就可以求解了。推导过程如下:
用 V 表示碰撞前车的速度,V   表示碰撞后车的速度;用V 0  表示碰撞前球的速度,用V  0  表示碰撞后球的速度;用M 表示车的质量m 表示球的质量。(M>>m )
{12 MV 2 +12 mV 2 0 =12 MV   2 +12 mV   2 0 MV+mV 0 =MV  +mV  0   

 {12 M(V+V  )(VV  )=12 m(V 0 +V  0 (V  0 V 0 ))M(VV  )=m(V  0 V 0 )  

 可将 约成V+V  =V 0 +V  0  
然后将V   视作V ,可得V  0 =2VV 0  

#include <iostream>

using namespace std;

int main()
{
    int v,v0;
    while(cin>>v>>v0)
    {
        int v1;
        v1 = 2*v - v0;
        cout<<v1<<endl;
    }
    return 0;
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值