@codeforces - 1187F@ Expected Square Beauty】的更多相关文章

目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定一个序列 x = {x1, x2, ..., xn},已知 xi 是一个在 [li, ri] 内的随机整数. 令 B(x) 表示将序列 x 划分成若干连续的段,使每个段内所有数相同的最小划分数. 求 (B(x))^2 的期望 E((B(x))^2). Input 第一行包含一个整数 n (1≤n≤2⋅10^5))表示序列长度. 第二行包含 n 个整数 l1,…
F - Expected Square Beauty 思路:https://codeforces.com/blog/entry/68111 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/stdc++.h> using namespace std; #define y1 y11 #define fi first #define se second #define…
题目 CF1187F Expected Square Beauty 做法 \(B(x)=\sum\limits_{i=1}^n I_i(x),I_i(x)=\begin{cases}1&x_i≠x_{i-1}\\0&x_i=x_{i-1}\end{cases}\) \(E(B(x)^2)=E(\sum\limits_{i=1}^n I_i(x)\sum\limits_{j=1}^n I_j(x))=E(\sum\limits_{i=1}^n\sum\limits_{j=1}^n I_i(x…
Codeforces 828B Black Square(简单题) Description Polycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's "Black Square", Polycarp wants to paint minimum pos…
A - Theatre Square Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 1A Description Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the…
题目链接:http://codeforces.com/problemset/problem/710/C 题目大意:输入一个奇数n,则生成n*n矩阵,要求矩阵的行.列还有斜着,所有元素之和为奇数. 解题思路:要符合行.列还有斜着,所有元素之和为奇数,则保证行.列或者斜着,有奇数个奇数 和 偶数个偶数即可. 32 4 8 5 2 4 6 8 10 3 5 7 12 9 11 13 15 17 14 19 21 23 16 18 20 22 24 7 2 4 6 8 10 12 14 16 3 5 7…
B. Petya and Square time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Petya loves playing with squares. Mum bought him a square 2n × 2n in size. Petya marked a cell inside the square…
Expected diameter of a tree 我们先两次dfs计算出每个点能到达最远点的距离. 暴力计算两棵树x, y连边直径的期望很好求, 我们假设SZ(x) < SZ(y) 我们枚举 x 的每个端点, 二分找到分界点, 复杂度为SZ(x) * log(SZ(y)) 其实我们对于每次询问我们记忆化一下就可以啦. 这是因为对于SZ(x)小于 sqrt(n)的询问, 我们直接暴力求就好啦, 复杂度q * SZ(x) * log(SZ(y)) 对于SZ(x) > sqrt(n) 这样的…
D. Expected diameter of a tree time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Pasha is a good student and one of MoJaK's best friends. He always have a problem to think about. Today they…
C. Square Subsets time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number…