2018杭电多校第六场

 

 A.oval-and-rectangle   

Problem Description

Patrick Star find an oval.

The half of longer axes is on the x-axis with length a .

The half of shorter axes is on the y-axis with length b .

Patrick Star plan to choose a real number c randomly from [0,b] , after that, Patrick Star will get a rectangle :

1. The four vertexes of it are on the outline of the oval.

2. The two sides of it parallel to coordinate axis.

3. One of its side is y=c .

Patrick Star want to know the expectations of the rectangle's perimeter.

 

 

Input

The first line contain a integer T (no morn than 10), the following is T test case, for each test case :

Each line contains contains two integer a, b (0<b<a<105 ). Separated by an white space.

 

 

Output

For each test case output one line denotes the expectations of the rectangle's perimeter .

You should keep exactly 6 decimal digits and ignore the remain decimal digits.

It is guaranted that the 7-th decimal digit of answer wont be 0 or 9.

 

 

Sample Input

 

1 2 1

 

 

Sample Output

 

8.283185

 

题解:主要卡精度

 

 

#include<bits/stdc++.h>
#define pi acos(-1)
using namespace std;
int main()
{
    int t,n,m;
    scanf("%d",&t);
    while (t--){
        scanf("%d%d",&n,&m);
        double r=pi*n+2*m;
        long long s=r*1e6;
        printf("%.6lf\n",s/1e6);
    }
    return 0;
}

 

 

 

 

L.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

 

解题:物理题

#include<bits/stdc++.h>
using namespace std;
const double g = 9.8;
int main()
{
    int T;
    double h, x, y, a, b;
    cin >> T;
    while(T--)
    {
        scanf("%lf %lf %lf %lf", &a, &b, &x, &y);
        double tans = fabs(b) / fabs(a);
        double sins = fabs(b) / sqrt(a*a+b*b);
        double coss = fabs(a) / sqrt(a*a+b*b);
        double h= fabs(x) * tans;
        double v0=sqrt(2.0 * g * (y - h));
        double t =2.0 * v0 / g;
        double len=sqrt(x*x+h*h);
        double vx=v0 * sins;
        double gx=g * sins;
        int cnt = 0;
        while(len>= 1)
        {
            len-=  (vx * t + 0.5 * gx * t * t);
            vx+= gx * t;
            cnt++;
        } 
        printf("%d\n", cnt);
    }
    return 0;
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值