intmain(){ scanf("%I64d", &n); int ans = 0; for (int i = 0; i < 33; i++){ if (n > (1ll << i)) n -= (1ll << i), ans++; elsebreak; } if (n) ans++; printf("%d", ans); return0; }
intmain(){ scanf("%d%d", &n, &s); for (int i = 0; i < n; i++) scanf("%d", a + i); sort(a, a + n); int k = upper_bound(a, a + n, s) - a; ll ans = 0; // printf("%d\n", k); if (k > n / 2){ for (int i = n / 2; i < k; i++){ ans += 1ll * abs(s - a[i]); } } else{ for (int i = k; i <= n / 2; i++){ ans += 1ll * abs(a[i] - s); } } printf("%I64d", ans); return0; }
vector<int> edge[maxn]; int n, a[maxn], vis[maxn];
intbfs(){ vis[1] = 1; int l = 0, s = 1; while (l < s){ int t = a[l]; set<int> p, q; for (int v : edge[t]) if (!vis[v]) p.insert(v); for (int i = s; i < s + p.size(); i++) q.insert(a[i]); if (p != q) return0; for (int i : p) vis[i] = 1; s += p.size(); l++; } return1; }
intmain(){ scanf("%d", &n); for (int i = 0, x, y; i < n - 1; i++){ scanf("%d%d", &x, &y); edge[x].push_back(y); edge[y].push_back(x); } for (int i = 0; i < n; i++) scanf("%d", a + i); if (a[0] != 1) {puts("No"); return0;} if (bfs()) puts("Yes"); elseputs("No"); return0; }
vector<int> q; vector<PII> edge[maxn]; int from[maxn], to[maxn], deg[maxn], vis[maxn]; int n, m, k, ans[maxn];
intmain(){ scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < m; i++){ scanf("%d%d", from + i, to + i); deg[from[i]]++; deg[to[i]]++; edge[from[i]].emplace_back(to[i], i); edge[to[i]].emplace_back(from[i], i); } for (int i = 1; i <= n; i++){ if (deg[i] < k){ q.push_back(i); } } int l = 0; for (int i = m - 1; i >= 0; i--){ while (l < q.size()){ int t = q[l]; for (PII v : edge[t]){ if (vis[v.second]) continue; vis[v.second] = 1; deg[v.first]--; deg[t]--; if (deg[v.first] == k - 1) q.push_back(v.first); } l++; } ans[i] = n - q.size(); if (vis[i]) continue; vis[i] = 1; deg[from[i]]--; deg[to[i]]--; if (deg[from[i]] == k - 1) q.push_back(from[i]); if (deg[to[i]] == k - 1) q.push_back(to[i]); } for (int i = 0; i < m; i++) printf("%d\n", ans[i]); return0; }