acgo题库
  • 首页
  • 题库
  • 学习
  • 天梯
  • 备赛

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
  • 竞赛
  • 讨论
  • 团队
登录
注册
题目详情提交记录(0)
  • 讨论

    谁能解释一下这是啥原因? #include <bits/stdc++.h> using namespace std; struct node{ long long sum,id; double k; }man[110]; long long n,m,p,a[100010]; bool cmp(node a,node b){ if(a.sumb.sum){ if(a.kb.k){ a.id<b.id; } a.k<b.k; } a.sum>b.sum; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>m>>p; for(int i=1;i<=n;i++){ man[i].id=i; for(int j=1;j<=m;j++){ cin>>a[j]; man[i].sum+=a[j]; } long long ba=man[i].sum/m,cnt=0; for(int j=1;j<=m;j++){ cnt+=pow(abs(a[j]-ba),2); } man[i].k=cnt/m; } sort(man+1,man+n+1,cmp); cout<<man[p].id; } 输出的全是RE

    userId_undefined

    stars_dream(emo)

    出道萌新空间掌握者循环·循环打卡人字符串·魔法使数组·数组操作员
    53阅读
    2回复
    3点赞
暂无数据

提交答案之后,这里将显示提交结果~

首页