hdu6373 多校第6场 Pinball
Problem Description
There is a slope on the 2D plane. The lowest point of the slope is at the origin. There is a small ball falling down above the slope. Your task is to find how many times the ball has been bounced on the slope.
It's guarantee that the ball will not reach the slope or ground or Y-axis with a distance of less than 1 from the origin. And the ball is elastic collision without energy loss. Gravity acceleration g=9.8m/s2.
Input
There are multiple test cases. The first line of input contains an integer T (1 ≤ T ≤ 100), indicating the number of test cases.
The first line of each test case contains four integers a, b, x, y (1 ≤ a, b, -x, y ≤ 100), indicate that the slope will pass through the point(-a, b), the initial position of the ball is (x, y).
Output
Output the answer.
It's guarantee that the answer will not exceed 50.
Sample Input
1 5 1 -5 3
Sample Output
2
将重力分解为斜面方向和垂直斜面方向,那么在斜面方向做匀加速运动,设时间为tx,在垂直斜面方向做上下的运动 设碰撞后 时间为ty ,那么次数为 (tx/ty)/2 如果tx/ty为奇数还要加1
#pragma GCC optimize(2)
#include<stdio.h>
#include<string.h>
#include<string>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<stdlib.h>
#include<time.h>
#include <iomanip>
#define lowbit(x) (x&(-x))
#define inf 0x7fffffff
#define linf 0x7fffffffffffffff
#define mem(x,y) memset(x,y,sizeof(x))
#define fup(i,x,y) for(int i=(x);i<=(y);i++)
#define fdn(i,x,y) for(int i=(x);i>=(y);i--)
#define sp(x) setprecision(x)
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d%d",&n,&m)
#define sddd(n,m,k) scanf("%d%d%d",&n,&m,&k)
#define sld(n) scanf("%lld",&n)
#define sldd(n,m) scanf("%lld%lld",&n,&m)
#define slddd(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define sf(n) scanf("%lf",&n)
#define sff(n,m) scanf("%lf%lf",&n,&m)
#define sfff(n,m,k) scanf("%lf%lf%lf",&n,&m,&k)
#define sc(n) scanf("%s",n)
#define pf(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define pff(x) printf("%lf\n",x)
#define debug printf("!!\n");
#define N 100005
#define M 4000009
#define pi acos(-1)
#define eps 1e-2
//cout.setf(ios::fixed);
//freopen("out.txt","w",stdout);// freopen("in.txt","r",stdin);
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
int main()
{
int t;
sd(t);
while(t--)
{
db a,b,x,y;
sff(a,b);
sff(x,y);
db d=atan(y/(-x));
db d1=atan(b/a);
int s=(int)sqrt(1/((tan(d-d1))*tan(d1)));
if(d<d1) s=0;
pf(s/2+(s%2?1:0));
}
}
上一篇: #2020寒假集训#数论入门(Number Theory)代码笔记
下一篇: 浅谈-二分查找
推荐阅读
-
2020牛客多校第3场[Clam and Fish+贪心]
-
2017多校第4场 HDU 6074 Phone Call 并查集,LCA
-
2020牛客多校第3场:Two Matchings[找规律+dp]
-
2020牛客多校第3场:[Points Construction Problem + 思维题+构造]
-
牛客多校第9场E Groundhog Chasing Death
-
hdu6373 多校第6场 Pinball
-
2020牛客多校第3场[Clam and Fish+贪心]
-
2018多校第3场 G题 && HDU6325 Problem G. Interstellar Travel
-
2020牛客多校第3场:Two Matchings[找规律+dp]
-
2020牛客多校第3场:[Points Construction Problem + 思维题+构造]