当前位置:网站首页>(2022 Niu Ke Duo School IV) N-Particle Arts (Thinking)
(2022 Niu Ke Duo School IV) N-Particle Arts (Thinking)
2022-08-01 04:50:00 【AC__dream】
Title:
Sample input:
51 2 3 4 5
Sample output:
54/5
Title:
n particles, each with an energy ai.For a random collision of two pairs, if the energies of the two examples are a and b, respectively, then the energies of the two particles in one collision become a&b, a|b respectively.Find the variance of all particle energies after they have stabilized.
We analyze the results of the collision of two particles and we can find that for the binary bits of a and b, if the i-th bit is both 1, then the i-th bit of the energy of the two particles formed after the collision is both 1,If the i-th bit is both 0, then the i-th bit of the energy of the two particles formed after the collision is 0. If the i-th bit of the a-particle and b-particle energy before the collision is 1 and the other is 0, then the collision is formed.The i-th bit of the particle is also a 1 and a 0, but the 1 is on the particle after the OR operation, so it is easy to find that each collision will make the energy of a particle larger (or may remain unchanged), and the binary bit after the collisionThe number of 1s remains unchanged, but it is possible to transfer from 1 particle to another particle. Due to countless collisions, the 1s on the binary must be concentrated as much as possible on a few, The final stable state is that for any i and j, there are (ai|aj,ai&aj)=(ai,aj) or (ai|aj,ai&aj)=(aj,ai) .So we only need to count the number of occurrences of 1 in each of the n numbers given at the beginning.Assign n numbers, try to assign 1 to a number every time, and finally ask for the expectation.
One point to note is that because the number is relatively large, it may explode long long, so it is recommended to use __int128 for calculation directly.
Here is the code:
#include#include#include#include#include
边栏推荐
- 罗技鼠标体验记录
- Visual Studio提供的 Command Prompt 到底有啥用
- typescript19-对象可选参数
- Pyspark Machine Learning: Vectors and Common Operations
- 25. Have you been asked these three common interview questions?
- 【无标题】
- Dry goods!How to Construct SRv6-TE Performance Test Environment Using Instrumentation
- 【kali-信息收集】枚举——DNS枚举:DNSenum、fierce
- 请问表格储存中用sql只能查询到主键列,ots sql非主键不支持吗?
- typescript28 - value of enumeration type and data enumeration
猜你喜欢
随机推荐
深圳某游戏研发公司给每个工位都装监控,网友:堪比坐牢!
The method of solving stored procedure table name passing through variable in mysql
怀念故乡的面条
Excel做题记录——整数规划优化模型
Mysql中的数据类型和运算符
LeetCode 1189. “气球” 的最大数量
Dynamic Programming 01 Backpack
PMP 相关方管理必背总结
/etc/fstab
阿叶的目标
挑战52天背完小猪佩奇(第01天)
数组问题之《两数之和》以及《三数之和 》
[FPGA tutorial case 43] Image case 3 - image sobel edge extraction through verilog, auxiliary verification through MATLAB
typescript26 - literal types
这里有110+公开的专业数据集
Lawyer Interpretation | Guns or Roses?Talking about Metaverse Interoperability from the Battle of Big Manufacturers
What is dynamic programming and what is the knapsack problem
【愚公系列】2022年07月 Go教学课程 024-函数
在沈自所的半年总结
文件的异步读写