QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#481867 | #7637. Exactly Three Neighbors | CelestialCoder | TL | 0ms | 0kb | C++20 | 1.2kb | 2024-07-17 15:21:41 | 2024-07-17 15:21:42 |
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