QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#481867#7637. Exactly Three NeighborsCelestialCoderTL 0ms0kbC++201.2kb2024-07-17 15:21:412024-07-17 15:21:42

Judging History

你现在查看的是最新测评结果

  • [2024-07-17 15:21:42]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-07-17 15:21:41]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

const int u = 16;
const int T = 64;
const ld alpha = 2;
const ld V = (ld)T * ((1ll<<(2*u))-1) / 12;
const ll MAX_U = (1 << u) * T;

ld unif_tab[MAX_U];

void unif() {
    for (int i=0; i<MAX_U; ++i) unif_tab[i] = 1.0;
    for (int r=0; r<T; ++r) {
        for (int i=MAX_U-1; i>=0; --i) {
            unif_tab[i] = (unif_tab[i] - (i >= (1<<u) ? unif_tab[i-(1<<u)] : 0)) / (1 << u);
        }
        if (r == T-1) break;
        for (int i=1; i<MAX_U; ++i) unif_tab[i] += unif_tab[i-1];
    }
}

void solve() {
    unif();
    
    ld A = 0;
    for (int x = -(1<<(u-1))*T; x <= ((1<<(u-1))-1)*T; ++x) {
        A += exp(-(ld)x*x/2/V);
    }

    ld renyi = 0;
    for (int x = -(1<<(u-1))*T + T/2; x <= ((1<<(u-1))-1)*T + T/2; ++x) {
        ld num = pow(unif_tab[x + (1<<(u-1))*T - T/2], alpha);
        ld deno = pow(exp(-(ld)x*x/2/V) / A, alpha-1);
        renyi += num / deno;
    }
    
    renyi = pow(renyi, (ld)1/(alpha-1));
    cout << renyi;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cout << fixed << setprecision(12);
    solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

2 3

output:

1.000014655901

result: