首页 > 学院 > 开发设计 > 正文

BZOJ 2456, Mode

2019-11-06 07:51:02
字体:
来源:转载
供稿:网友

PRoblem

传送门

Mean

给定一个数列,试求其众数。

Analysis

内存限制的脑洞题。 感觉自己已经未老先衰了…… 主要是运用相消的思想,具体看代码吧……描述无能。

Code

#include<cstdio>int n,x,t,cnt;int main(){ scanf("%d",&n); while(n--){ scanf("%d",&x); if(!cnt) t=x,cnt++; else if(t==x) cnt++; else cnt--; } printf("%d",t); return 0;}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表