K - Kindergarten Physics

https://vjudge.net/contest/386568#problem/K

Zhang3 a participant of IPhO (Immortal Physics Olympiad). The  0th0th problem in the contest is as follows.

There are two balls that weigh aa kg and bb kg respectively. They can be regarded as particles in this problem, as they are small enough. At the very beginning (i.e. t=0t=0), the distance between two balls is dd km, and both of them are not moving.

Assuming that only gravitation works in this system (no other objects or other forces considered). The two balls has started moving since t=0t=0. Your task is to calculate the distance between them when t=t0t=t0 (s).

Help Zhang3 solve the problem!



The following information might help when solving the problem.

- Universal gravitation formula: F=Gm1m2/r2F=G⋅m1⋅m2/r2

- Gravitational constant: G=6.67430×1011m3/(kgs2)G=6.67430×10−11m3/(kg⋅s2)

InputThe first line of the input gives the number of test cases T(1T100)T(1≤T≤100). TT test cases follow.

For each test case, the only line contains four integers a,b,d,t0(1a,b,d,t0100)a,b,d,t0(1≤a,b,d,t0≤100), representing the mass of the two balls, the initial distance between them, and how much time the balls move.

It is guaranteed that two balls will not collide within (t0+1)(t0+1) seconds.
OutputFor each test case, print a line with a real number xx, representing that the distance is xx km.

Your answers should have absolute or relative errors of at most 10610−6.
Sample Input

3
1 2 3 4
7 73 7 68
100 100 1 100

Sample Output

2.99999999999999999982
6.99999999999999974807
0.99999999999993325700


水题:只受万有引力 影响极小 不足精度
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include <vector>
#include <iterator>
#include <utility>
#include <sstream>
#include <limits>
#include <numeric>
#include <functional>
using namespace std;
#define gc getchar()
#define mem(a) memset(a,0,sizeof(a))
//#define sort(a,n,int) sort(a,a+n,less<int>())

#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef char ch;
typedef double db;

const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;
const int maxm=100+10;
const int N=2e5+10;
const int mod=1e9+7;
 
int main()
{
	int T = 0;
	int a = 0 , b = 0 , d = 0 , t = 0;
	cin >> T;
	while(T--)
	{
		
		cin >> a >> b >> d >> t;
		cout<< d <<endl;
	}
	return 0;	
} 

  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YukiRinLL

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值