hdu 5066 Harry And Physical Teacher(物理)
2016-07-09 09:36
417 查看
Harry And Physical Teacher
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 628 Accepted Submission(s): 339
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 V0 made
a completely elastic collision with a car moving towards the same direction with a speed V(V<V0),
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 V0 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
题意:一个速度为v0的小球和一个速度为v的汽车在同一个方向上运动,小球在车后面,车的质量远远大于小球,两者之间碰撞时完全弹性碰撞,问小球撞完后的速度是多少
思路:联立动能定理和动量守恒定理可以得到v=2*v1-v0
代码:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int main()
{
long long n,m;
while(~scanf("%lld %lld",&n,&m))
{
if(n>m) swap(n,m);
printf("%lld\n",2*n-m);
}
return 0;
}
相关文章推荐
- SAP中:ALE控制单元是什么?
- java堆栈区别
- poj 3321(树状数组)
- 如何使用CommitMonitor工具监控 SVN
- mysql-python安装时EnvironmentError: mysql_config not found
- getCacheDir()、getFilesDir()、getExternalFilesDir()、getExternalCacheDir()的作用
- HDU 5308 I Wanna Become A 24-Point Master (暴力枚举+构造)
- 数据库关系模式题型大全
- Asp.net中,点击GridView表头实现数据的排序
- DDL、DML和DCL的理解
- 欢迎使用CSDN-markdown编辑器
- 跟我一起学Multiple View Geometry多视图几何(6)
- php不定参数方法(函数)和可选参数方法(函数)
- 解决 MySQL 的 Table is marked as crashed and should be repaired 问题
- Linux基础-----find和重定向命令
- 面试冒泡排序
- SAP XI
- pta--七桥问题
- hdfs的shell命令
- 几个关于Service的知识点