【神奇の做法】bzoj2456 mode

题解:http://www.tuicool.com/articles/BfQBzif

 1 #include<cstdio>
 2 using namespace std;
 3 int n,x,ans,tot;
 4 int main()
 5 {
 6     scanf("%d",&n);
 7     for(;n>0;n--)
 8       {
 9           scanf("%d",&x);
10           if(!tot) {ans=x; tot=1;}
11           else if(x==ans) tot++;
12           else tot--;
13       }
14     printf("%d
",ans);
15     return 0;
16 }
原文地址:https://www.cnblogs.com/autsky-jadek/p/4060679.html