UOJ Logo 837951602的博客

博客

UOJ系统能不能出polyglot题

2024-04-13 12:45:18 By 837951602

比如:写段程序,用C运行输出C,用C++运行输出C++

latex怎么写长等号

2023-12-25 12:01:18 By 837951602

$$\begin{aligned} ~&\frac{\sin\left(x\right)-x}{x^3}\\ =&\frac{x-\frac{x^3}6+\frac{x^5}{120}+\mathrm O\left(x^7\right)-x}{x^3}\\ =&-\frac 16+\frac{x^2}{120}+\mathrm O\left(x^4\right)\\ \overset{x\rightarrow 0}{=}&-\frac 16\\ &\text{Can I make "=" long?} \end{aligned}$$

另外有没有教材都保留一个余项的,就不会老有人问为啥$sin(x)\sim x$却不能直接代

Mth.atan2

2023-10-21 13:00:57 By 837951602

Mth.atan2 源码

public static double atan2(double d, double e) {
    double f = e * e + d * d;
    if (Double.isNaN(f)) {
        return Double.NaN;
    } else {
        boolean bl = d < 0.0;
        if (bl) {
            d = -d;
        }

        boolean bl2 = e < 0.0;
        if (bl2) {
            e = -e;
        }

        boolean bl3 = d > e;
        if (bl3) {
            double g = e;
            e = d;
            d = g;
        }

        double g = fastInvSqrt(f);
        e *= g;
        d *= g;
        double h = FRAC_BIAS + d;
        int i = (int)Double.doubleToRawLongBits(h);
        double j = ASIN_TAB[i];
        double k = COS_TAB[i];
        double l = h - FRAC_BIAS;
        double m = d * k - e * l;
        double n = (6.0 + m * m) * m * 0.16666666666666666;
        double o = j + n;
        if (bl3) {
            o = Math.PI / 2 - o;
        }

        if (bl2) {
            o = Math.PI - o;
        }

        if (bl) {
            o = -o;
        }

        return o;
    }
}

其中COS_TAB其实应该是COSASIN_TAB[i]

变量命名得

double MthAtan2(double y, double x) {
    double Len2 = y * y + x * x; // Len²
    if (Len2 != Len2) { // NaN
        return Len2;
    }
    bool NegY = y < 0.0;
    if (NegY) {
        y = -y;
    }
    bool NegX = x < 0.0;
    if (NegX) {
        x = -x;
    }
    bool SwapXY = y > x;
    if (SwapXY) {
        double t = y; y = x; x = t;
    }
    double InvLen = fastInvSqrt(Len2);
    x *= InvLen;
    y *= InvLen;
    // 加上该值可将精度控制为1/256
    const double FRAC_BIAS = 17592186044416.0;
    double bias_y = FRAC_BIAS + y;
    // i = y * 256
    int i = *(int*)&bias_y;
    double asinry = ASIN_TAB[i];
    double cosasinry = COS_TAB[i];
    double rounded_y = bias_y - FRAC_BIAS;
    double m = y * cosasinry - x * rounded_y;
    // m + m^3/6
    double delta = (6.0 + m * m) * m * (1.0 / 6.0);
    double ret = asinry + delta;
    if (SwapXY) {
        ret = PI / 2 - ret;
    }
    if (NegX) {
        ret = PI - ret;
    }
    if (NegY) {
        ret = - ret;
    }
    return ret;
}

仅分析[0,45°]角,在$\left(x,y\right)$附近查表找到点$\left(\tilde x,\tilde y\right)$,并计算

$$ m = y \cdot \tilde x - x \cdot \tilde y $$ $$ \sin^{-1} y = \sin^{-1} \tilde y + m + \frac{m^3}6 $$

然后就不会了

直接上程序计算,误差为

Any fast solution?

2023-02-15 00:37:25 By 837951602

$$\text{Decide if the following equation has solution:}$$ $$A_{m \times n} \cdot B_{n \times k} = X_{m \times k}$$ $$M \preceq A \preceq N, P \preceq B \preceq Q$$ $$\text{Where } F\preceq G \text{ means every element in }F\text{ is }$$ $$\text{smaller than the value on same position of }G$$ $$ X, M, N, P, Q \text{ are known}$$

EDIT@23/02/15 13:27: 用机械结构求解会卡住吗?

FFT利用复数减少一半点

2020-04-16 12:52:04 By 837951602

我看#34的榜,double做法都是 $$x_i=a_{2i}+ia_{2i+1}\\Z_i=X_iY_i-\frac 14\left(1+w_N^i\right)\left(X_i-\overline{X_{N-i}}\right)\left(Y_i-\overline{Y_{N-i}}\right)$$ 而不是 $$x_i=a_iu^i+a_{i+n}u^{i+n}\\Z_i=X_iY_i$$ 这两个方法,哪个更显然?哪个效率高?(我提交改了输出挂还去了swap过程,但另一种方法也能做)

837951602 Avatar