3221. 北京记者跑得最快

10175102141

北京记者的速度真的是快的一匹

10152130146

这个题目出的啊,excited

Fifnmar

只有做做水题才能维持得了生活的样子……

For each x, we have
12at2+v0tx=0,
and it is obvious that
t=v0+v02+2axa.
We can easily notice that it can be transformed into
t=v02a2+2xav0a.
To avoid repeated calculation, let
α=v02a2,β=v0a,θ=2a,
we have
t=α+βx+θ.

Now, for each case, we only need two addition, one multiplication, and one square root calculation.

Hence is the code:

#include <cmath>
#include <cstdio>

int main() {
    int l, v0, a;
    scanf("%i%i%i", &l, &v0, &a);
    double c = -(double)v0 / a;
    double b = c * c;
    double d = 2.0 / a;
    for (int i = 1; i <= l; ++i)
        printf("%.9lf\n", std::sqrt(b + d * i) + c);
}
Chains.Z
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
    double l, v, a;
    cin >> l >> v >> a;
    for (double x = 1; x <= l; x++)
    {
        double delta = sqrt(v*v + 2*a*x);
        double time = (delta - v) / a;
        cout << setprecision(9) << time << endl;
    }
}
存在问题!
||||
 
你当前正在回复 博客/题目 100:0