#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 201, mod = 1e9+7;
int q, n, ans, dis[N], cnt[N];
int pw(int x, int y) {
return (!y ? 1 : pw(x*x % mod, y >> 1) * (y & 1 ? x : 1) % mod);
}
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> q;
for (int i = 0; i < q; i++) {
cin >> n;
ans = 0;
for (int i = 1; i <= n; i++) {
memset(dis, -1, sizeof(dis));
memset(cnt, 0, sizeof(cnt));
queue<pair<int, int>> q;
q.push(make_pair(0, i));
while (!q.empty()) {
int d = q.front().first;
int x = q.front().second;
q.pop();
if (dis[x] != -1) continue;
dis[x] = d;
cnt[d]++;
if (x/2 >= 1 && dis[x/2] == -1) q.push(make_pair(d+1, x/2));
if (x*2 <= n && dis[x*2] == -1) q.push(make_pair(d+1, x*2));
if (x*2 + 1 <= n && dis[x*2 + 1] == -1) q.push(make_pair(d+1, x*2 + 1));
}
for (int j = n-1; j > 0; j--) {
ans += j * ((pw(2, cnt[j]) - 1 + mod) % mod) % mod * pw(2, cnt[j+1]) % mod;
cnt[j] += cnt[j+1];
}
}
cout << ans * pw((pw(2, n) - 1 + mod) % mod, mod-2) % mod << "\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |