当前位置:网站首页>“蔚来杯“2022牛客暑期多校训练营4 N
“蔚来杯“2022牛客暑期多校训练营4 N
2022-08-04 12:23:00 【eyuhaobanga】
将答案的公式结合起来化简可得
,
这样不会爆long long,只需要处理出最终趋于稳定的数组的形式,可知a+b=a&b+a|b,操作无数次,总和是不变的
AC代码:
#include <bits/stdc++.h> #define rep(i,a,n) for(int i=a;i<n;i++) using namespace std; using LL = long long; LL gcd(LL x, LL y) { return y == 0 ? x : gcd(y, x % y); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); LL n; cin >> n; vector<LL> a(n + 1); LL maxx = 0; LL sum = 0; vector<LL> pos(16, 0); for (int i = 1; i <= n; i ++ ) { cin >> a[i]; sum += a[i]; } if (sum == 0) { cout << "0/1\n"; return 0; } for (int i = 1; i <= n; i ++ ) { for (int j = 0; j <= 15; j ++ ) { if(1 << j & a[i]) { pos[j]++; } } } vector<LL> x; for (int i = 1; i <= n; i ++ ) { LL t = 0; for (int j = 15; j >= 0; j -- ) { if(pos[j]) { t += (1 << j); pos[j]--; } } if(t) x.push_back(t); else break; } int len = x.size(); LL ans = -sum * sum; for (int i = 0; i < n; i++) { if (i < len) ans += n * x[i] * x[i]; else { break; } } LL c = gcd(ans, n * n); cout << ans / c << "/" << n * n / c << '\n'; return 0; }
边栏推荐
猜你喜欢

Neck modules of the yolo series

Linux-Docker-Mysql安装

聪明的儿子处理婆媳关系的方法(处理婆媳关系的方法)

Focus!2022 interview must brush 461 interview questions summary + interview + resume template

如何过一个充满科技感的七夕?华为告诉你

电源测试之输出动态响应(Output Dynamic Response Test)

新消费、出海、大健康......电子烟寻找“避风港”

《独行月球》猛药,治不了开心麻花内耗

MATLAB——图像分块

Transferring Rich Feature Hierarchies for Robust
随机推荐
Flutter使用 json_serializable 解析 JSON 最佳方案
十一、网络规划设计
Matlab记录
接入华为游戏防沉迷,点击防沉迷弹窗后游戏闪退
Flutter教程大全合集(2022年版)
一分钟认识 IndexedDB 数据库,太强大了!
A comprehensive understanding of MOS tubes, an article is enough
03 多线程与高并发 - ReentrantLock 源码解析
集群监控——Zabbix
小程序在政务服务平台建设中如何发挥价值
开发小程序插件如何实现盈利?
第10章 模块和包
【VSCode】一文详解vscode下安装vim后无法使用Ctrl+CV复制粘贴 使用Vim插件的配置记录
ECCV 2022 | 通往数据高效的Transformer目标检测器
Cache character stream
String是引用类型
电源测试之输出动态响应(Output Dynamic Response Test)
什么是 DevOps?看这一篇就够了!
力扣每日一题-第48天-345. 反转字符串中的元音字母
他是“中台”之父,凭一个概念为阿里狂赚百亿
,
