当前位置:网站首页>踩水坑2 数据超出long long
踩水坑2 数据超出long long
2022-07-31 09:30:00 【繁水682】
不能想当然认为数据一定小于long long
一定要仔细判断数据范围!
一定要仔细判断数据范围!
一定要仔细判断数据范围!
如果不行了,就可以用赖皮方法,__int128(两个下划线)
__int128只能用于数据中间处理,不能用作输入输出。
用法:
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define pii pair<int,int>
#define pb push_back
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define nep(i,r,l) for (int i=r;i>=l;i--)
#define CIO std::ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
const int N=2e6+5;
int aa[N];
int bb[N];
map<int,int> m;
void lg(int x){
int cnt=0;
while (x){
if (x&1) m[cnt+1]++;
x=x/2;
cnt++;
}
}
int ansz,ansm;
__int128 gcd(__int128 a,__int128 b){
if (b==0) return a;
return gcd(b,a%b);
}
int pre[40];
void work(){
int n;cin>>n;
int sum=0;
rep(i,1,n){
cin>>aa[i];
sum+=aa[i];
lg(aa[i]);
}
int SUM=sum;
pre[1]=1;
rep(i,2,30){
pre[i]=pre[i-1]*2;
}
rep(i,1,30){
rep(j,1,m[i]){
bb[j]+=pre[i];
}
}
__int128 ans=0;
__int128 zhuan=0;
rep(i,1,n){
zhuan=(bb[i]*n-SUM);
zhuan*=(bb[i]*n-SUM);
ans+=zhuan;
}
__int128 nn=n*n*n;
__int128 g=gcd(ans,nn);
int ans1=ans/g;
int ans2=(n*n*n)/g;
if (ans==0) cout<<"0/1";
else cout<<ans1<<"/"<<ans2;
}
signed main(){
CIO;
//int _;cin>>_;while(_--)
{
work();
}
return 0;
}
边栏推荐
猜你喜欢
随机推荐
5.for in 和 for of区别和使用
六、MFC文档类(单文档和多文档)
spark过滤器
js以变量为键
一次Spark SQL线上问题排查和定位
如何将亚马逊广告添加到您的 WordPress 网站(3 种方法)
loadrunner脚本--添加检查点
内联元素居中
Come n times with the sword--05. Replace spaces
jupyter notebook初使用
Browser usage ratio js radar chart
第二十四课、二十五课,高级光照(blinn),Gamma矫正
js滚动条滚动到指定元素
Come n times - 09. Implement queues with two stacks
期刊会议排名、信息检索网站推荐以及IEEE Latex模板下载
Flink1.15 source code reading - PER_JOB vs APPLICATION execution process
JSP config对象的简介说明
【TCP/IP】网络模型
7. JS ES6新增语法 new Map详讲,还有一道代码实战案例帮你快上手new Map
HTC官方RUU固件提取刷机包rom.zip以及RUU解密教程



![[NLP] Interpretation of Transformer Theory](/img/5f/8e1b9e48310817a0443eb445479045.png)





