当前位置:网站首页>"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;
}
边栏推荐
- ML之shap:基于FIFA 2018 Statistics(2018年俄罗斯世界杯足球赛)球队比赛之星分类预测数据集利用RF随机森林+计算SHAP值单样本力图/依赖关系贡献图可视化实现可解释性之攻略
- Chapter 8 Intermediate Shell Tools II
- StoneDB 为何敢称业界唯一开源的 MySQL 原生 HTAP 数据库?
- ThinkPHP高仿蓝奏云网盘系统源码/对接易支付系统程序
- vulnhub靶机AI-Web-1.0渗透笔记
- d使用among的问题
- #yyds干货盘点# 面试必刷TOP101:判断链表中是否有环
- mysql获取当前时间
- # # yyds dry goods inventory interview will brush TOP101: to determine whether there is a part of the list
- Go1.18升级功能 - 泛型 从零开始Go语言
猜你喜欢

ThinkPHP high imitation blue play cloud network disk system source code / docking easy payment system program
![[MySQL] DQL related operations](/img/a5/c92e0404c6a970a62595bc7a3b68cd.gif)
[MySQL] DQL related operations

2021GDCPC广东省大学生程序设计竞赛 H.History

MySQL连接时出现2003错误

【Untitled】

Gxlcms有声小说系统/小说听书系统源码

$\text{ARC 145}$

MySQL索引常见面试题(2022版)

IDEA usage skills

Go语学习笔记 - gorm使用 - 事务操作 Web框架Gin(十一)
随机推荐
ZZULIOJ:1119: 数列有序
力扣题(2)—— 两数相加
“蔚来杯“2022牛客暑期多校训练营4 N.Particle Arts 规律 方差
vscode上利用screen命令跑代码
2021GDCPC Guangdong University Student Programming Competition B.Byfibonacci
宁波中宁典当转让29.5%股权为283.38万元,2021年所有者权益为968.75万元
ZZULIOJ: 1120: the most value to exchange
Ningbo Zhongning Pawn will transfer 29.5% of the equity for 2.8338 million yuan, and the owner's equity in 2021 will be 9.6875 million yuan
关于XML的学习(一)
for...in 和 for...of 的区别
Successfully solved ImportError: always import the name '_validate_lengths'
2022.7.28
【翻译】作为混沌网的LFX门徒的经验
Gxlcms audio novel system/novel listening system source code
DFS题单以及模板汇总
连号区间数
2022牛客暑期多校训练营1 J Serval and Essay
d违反常了吗
Introducing the visualization tool Netron
IDEA使用技巧