Submission #466179

#TimeUsernameProblemLanguageResultExecution timeMemory
466179sinamhdvParty (INOI20_party)C++11
7 / 100
598 ms660 KiB
#include <bits/stdc++.h> using namespace std; #define int ll typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int mod = 1000 * 1000 * 1000 + 7; const int INF = 1e9 + 100; const ll LINF = 1e18 + 100; #ifdef DEBUG #define dbg(x) cout << #x << " = " << (x) << endl << flush; #define dbgr(s, f) { cout << #s << ": "; for (auto _ = (s); _ != (f); _++) cout << *_ << ' '; cout << endl << flush; } #else #define dbg(x) ; #define dbgr(s, f) ; #endif #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define pb push_back #define fr first #define sc second #define all(x) (x).begin(), (x).end() #define endl '\n' const int MAXN = 220; const int MAXH = 22; int q; ll n; int k; int dp[MAXN][MAXH]; ll ans; int h[MAXN]; int rt; vector<int> adj[MAXN]; inline void addedge(int x, int y) { adj[x].pb(y); adj[y].pb(x); } void dfs(int v, int par) { dp[rt][h[v]]++; for (int u : adj[v]) if (u != par) h[u] = h[v] + 1, dfs(u, v); } ll poww(ll a, ll b) { a %= mod, b %= mod; ll res = 1; while (b) { if (b & 1) res = res * a % mod; a = a * a % mod; b /= 2; } return res; } inline void tcase(void) { ans = 0; FOR(i, 0, MAXN) adj[i].clear(); memset(dp, 0, sizeof(dp)); cin >> n; FOR(i, 2, n + 1) { addedge(i, i/2); } FOR(i, 1, n + 1) { rt = i; h[i] = 0; dfs(i, -1); for (int x = MAXH - 2; x >= 0; x--) dp[i][x] += dp[i][x + 1]; ll val = 0; FOR(x, 1, MAXH - 1) val += (ll)x * (poww(2, dp[i][x]) - poww(2, dp[i][x + 1])) % mod; ans = (ans + val) % mod; } ans = ans * poww((poww(2, n) - 1) % mod, mod - 2) % mod; ans = (mod + ans % mod) % mod; cout << ans << endl; } int32_t main(void) { fast_io; cin >> q; while (q--) tcase(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...