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
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
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cstdio>
#include <set>
#include <math.h>
#include <algorithm>
#include <queue>
#include <iomanip>
#define INF 0x3f3f3f3f
#define MAXN 6005
#define Mod 99999999
using namespace std;
int main()
{
int v,v0;
while(cin>>v>>v0)
{
cout<<2*v-v0<<endl;
}
return 0;
}