2973——————出现次数超过一半的数 n=int(input())m=input().split()ifn==len(m):d={i:m.count(i)foriinm}b=max(d.values())ifb>n//2:#ifb>n/2:print(max(d,key=d.get))else:print('no')扩充知识c=zip(d 题解列表 2022年09月24日 0 点赞 0 评论 801 浏览 评分:9.9
没人写,就我来吧。 摘要:解题思路:注意事项:参考代码:#include<bits/stdc++.h>using namespace std;int main(){ int n,t,b[1005]={0}; cin>>n; i…… 题解列表 2022年10月24日 0 点赞 0 评论 569 浏览 评分:9.9
出现次数超过一半的数(C语言版) 摘要:解题思路:这里要一个存储个数的数组b,然后把各个数的个数放到b中。注意事项:注意这里加减50的原因是,数组的下标没有负数,其他的就没啥了。参考代码:#include<stdio.h>int main(…… 题解列表 2023年01月30日 0 点赞 0 评论 715 浏览 评分:9.9
2973: 出现次数超过一半的数 ```cpp#include#includeusingnamespacestd;intmain(){inta[1001],b[1001],n;memset(b,0,sizeof(b));cin>>n;for(inti=0;i>a[i];a[i]+=50;++b[a[i]];}for(inti=0;in 题解列表 2023年02月17日 0 点赞 0 评论 506 浏览 评分:9.9
2973: 出现次数超过一半的数 ```cpp//这道题我是用桶的思想去做的//有一点需要注意,是n的范围,从-50开始,但数组的下标是不会有负数的所以加上50即可#includeusingnamespacestd;inta[1001],b[2000],n,f;intmain(){cin>>n;for(inti=1;i>a[i];b[ 题解列表 2023年03月11日 0 点赞 0 评论 599 浏览 评分:9.9
2973: 出现次数超过一半的数 解题思路:注意事项:参考代码:#includeusingnamespacestd;typedeflonglongll;constllN=1e5;inttong[N];intmain(){intn;cin>>n;for(inti=1;i<=n;i++){inta;cin>>a;tong[a+50]++; 题解列表 2024年07月15日 0 点赞 0 评论 460 浏览 评分:9.9
编写题解 2973: 出现次数超过一半的数 摘要:解题思路:先计数排序 再判断注意事项:参考代码:#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N=…… 题解列表 2024年07月22日 0 点赞 0 评论 545 浏览 评分:9.9
出现次数超过一半的数 可AC 摘要:解题思路:注意事项:参考代码:#include<stdio.h>#include<malloc.h>#include<stdlib.h>int main(){ int n,flag=0,a[100]=…… 题解列表 2023年03月14日 0 点赞 0 评论 535 浏览 评分:0.0
c语言代码解决问题 摘要:解题思路:注意事项:参考代码:#include<stdio.h>int main(){ int n, i, j,a[1000],sum=1,max_sum=1,max_num; scanf…… 题解列表 2023年06月11日 0 点赞 0 评论 495 浏览 评分:0.0
2973: 出现次数超过一半的数 摘要:解题思路:注意事项:参考代码:#include <bits/stdc++.h>using namespace std;int tong[1005];int main(){ int n; c…… 题解列表 2023年10月21日 0 点赞 0 评论 629 浏览 评分:0.0