QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#496627#9136. Exponent Calculatorucup-team004AC ✓0ms3832kbC++201.2kb2024-07-28 13:58:072024-07-28 13:58:09

Judging History

This is the latest submission verdict.

  • [2024-07-28 13:58:09]
  • Judged
  • Verdict: AC
  • Time: 0ms
  • Memory: 3832kb
  • [2024-07-28 13:58:07]
  • Submitted

answer

#include <bits/stdc++.h>

using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    constexpr int T = 7;
    constexpr int B = 10;
    std::cout << std::fixed << std::setprecision(20);
    std::cerr << std::fixed << std::setprecision(20);
    
    // $1 = x
    double x = -20.0;
    std::cerr << std::exp(x) << "\n";
    x = x / (1 << B);
    std::cout << 2 * T + 1 + B << "\n";
    std::cout << "$1 = $1 * " << 1.0 / (1 << B) << "\n";
    
    double fac[T + 1];
    fac[0] = 1;
    for (int i = 1; i <= T; i++) {
        fac[i] = fac[i - 1] * i;
    }
    // $0 = ex
    double ex = x / fac[T];
    std::cout << "$0 = $1 * " << 1 / fac[T] << "\n";
    for (int i = T - 1; i >= 1; i--) {
        ex = ex + 1 / fac[i];
        std::cout << "$0 = $0 + " << 1 / fac[i] << "\n";
        ex = ex * x;
        std::cout << "$0 = $0 * $1\n";
    }
    ex = ex + 1.0;
    std::cout << "$0 = $0 + " << 1.0 << "\n";
    for (int i = 0; i < B; i++) {
        std::cout << "$0 = $0 * $0\n";
        ex = ex * ex;
    }
    std::cerr << ex << "\n";
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3832kb

input:

input

output:

25
$1 = $1 * 0.00097656250000000000
$0 = $1 * 0.00019841269841269841
$0 = $0 + 0.00138888888888888894
$0 = $0 * $1
$0 = $0 + 0.00833333333333333322
$0 = $0 * $1
$0 = $0 + 0.04166666666666666435
$0 = $0 * $1
$0 = $0 + 0.16666666666666665741
$0 = $0 * $1
$0 = $0 + 0.50000000000000000000
$0 = $0 * $1
$...

result:

ok max relative diff is 2.11491e-13. Checker runtime is 200 ms

Extra Test:

score: 0
Extra Test Passed