当前位置:网站首页>"Wei cup" school more than 2022 cattle summer camp 4 Nancy (polocy) pelosi article variance law of Arts
"Wei cup" school more than 2022 cattle summer camp 4 Nancy (polocy) pelosi article variance law of Arts
2022-07-30 22:57:00 【HeartFireY】
N.Particle Arts
题目大意
给定序列 a 1 , a 2 , … , a n a_1, a_2, \dots, a_n a1,a2,…,an,每当两个元素 a a a和 b b b相撞后会湮灭并产生两个新元素 a & b a \& b a&b和 a ∣ b a | b a∣b.若干次碰撞后,方差会收敛.求收敛后的方差.
首先可以发现,任意两个元素相撞变化后,不会引起总和的变化,因此均值是不变的.
那么考虑求经过无限此碰撞后生成的新序列,容易发现因为或操作的性质,二进制下为 1 1 1的位不会消失,那么无限次或操作会将为 1 1 1的位向同一数字靠拢.于是直接按位统计后生成新序列计算即可.
如果使用公式 E ( x 2 ) − E 2 ( x ) E(x^2) - E^2(x) E(x2)−E2(x),需要继续推式子;但可以直接怼上方差公式,但是又会爆long long
,那么可以在运算过程中全部使用__int128
计算,最后转long long
输出.
Code
#include <bits/stdc++.h>
#pragma gcc optimize("O2")
#pragma g++ optimize("O2")
#define int __int128
#define endl '\n'
using namespace std;
const int N = 2e5 + 10, MOD = 1e9 + 7;
long long a[N], b[N], cnt[20];
inline void solve(){
long long n = 0, sum = 0; cin >> n;
for(int i = 1; i <= n; i++) cin >> a[i], sum += a[i];
int cnt0 = 0, cnt1 = 0;
for(int i = 1; i <= n; i++){
for(int j = 0; j < 15; j++){
if((a[i] >> j) & 1) cnt[j]++;
}
}
for(int i = 0; i < 15; i++){
for(int j = 1; j <= cnt[i]; j++) b[j] |= (1 << i);
}
int f1 = 0;
for(int i = 1; i <= n; i++){
f1 += (n * b[i] - sum) * (n * b[i] - sum);
}
int f2 = n * n * n;
int gcdd = __gcd(f1, f2);
//cout << f1 << '@' << f2 << endl;
long long ans1 = f1 / gcdd, ans2 = f2 / gcdd;
//cout << (f1 / gcdd) << '/' << (f2 / gcdd) << endl;
cout << ans1 << '/' << ans2 << endl;
}
signed main(){
ios_base::sync_with_stdio(false), cin.tie(0);
cout << fixed << setprecision(12);
int t = 1; //cin >> t;
while(t--) solve();
return 0;
}
边栏推荐
- ZZULIOJ:1119: 数列有序
- WSL安装图形界面并通过xrdp/X-Launch访问
- QT 在父类中添加子类的流程,object tree,
- Apache Doris series: In-depth understanding of real-time analytical database Apache Doris
- Successfully resolved ModuleNotFoundError: No module named 'Image'
- “由于找不到MSVCP140.dll,无法继续执行代码,重新安装程序可能会解决此问题等”解决方案
- 连号区间数
- 抽象类和接口(学习笔记)
- Reverse linked list - head insertion inversion method
- grub 学习
猜你喜欢
PS基础学习(一)
Gxlcms audio novel system/novel listening system source code
打动中产精英群体,全新红旗H5用产品力跑赢需求
第十九周进度(了解物联网基础知识)
MySql统计函数COUNT详解
Learning about XML (1)
EasyExcel综合课程实战
IJCAI2022 Tutorial | Spoken Language Comprehension: Recent Advances and New Fields
When Navicat connects to MySQL, it pops up: 1045: Access denied for user 'root'@'localhost'
【科研】文献下载神器方式汇总
随机推荐
力扣题(3)—— 无重复字符的最长子串
2sk2225 Substitute 3A/1500V Chinese Documentation【PDF Data Book】
基于 Docker Compose 的 Nacos(MySQL 持久化)的搭建
[MySQL] Mysql transaction and authority management
网安学习-内网渗透3
$\text{ARC 145}$
【LeetCode】64. 最小路径和 - Go 语言题解
【2022-05-31】JS逆向之易企秀
PS基础学习(一)
When Navicat connects to MySQL, it pops up: 1045: Access denied for user 'root'@'localhost'
DFS题单以及模板汇总
Excel基础学习笔记
"NIO Cup" 2022 Nioke Summer Multi-School Training Camp 4 DHKLN
Gxlcms有声小说系统/小说听书系统源码
可视化工具Netron介绍
VS2017编译Tars测试工程
Day016 Classes and Objects
Detailed operator
MySQL进阶sql性能分析
电脑快捷方式图标变白解决方案