【BZOJ 2456】mode

相关链接

题目传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2456
神犇题解:https://oi.men.ci/bzoj-2456/

解题报告

考虑将不同的数抵消掉
因为题目所求的数多于一半
所以剩下的就一定是答案啦!

Code

#include<cstdio>
#define LL long long

int main() {
	int n,tot=0; LL num,cur;
	for (scanf("%d",&n);n;n--) {
		scanf("%lld",&cur);
		if (num != cur) {
			if (tot) tot--;
			else tot = 1, num = cur;
		} else tot++;
	} printf("%lld\n",num);
	return 0;
}

—– UPD 2016.12.29 —–
这题似乎还有一个做法:

考虑将原数分解成二进制
统计每一位二进制上0多还是1多

酱紫的话,最后在在二进制下逐位确定答案就好啦!

192 thoughts to “【BZOJ 2456】mode”

  1. Howdy! I just would like to offer you a huge thumbs up for
    the excellent info you’ve got right here on this post.
    I am returning to your site for more soon.

  2. Hey there! I realize this is sort of off-topic however I
    needed to ask. Does operating a well-established
    blog like yours require a massive amount work? I am completely new to operating a blog
    but I do write in my journal everyday. I’d like to
    start a blog so I can easily share my experience and thoughts
    online. Please let me know if you have any recommendations or tips for brand new
    aspiring bloggers. Thankyou!

  3. Magnificent goods from you, man. I have understand your stuff
    previous to and you’re just extremely great. I really
    like what you have acquired here, certainly like what you’re stating and the way in which you say it.
    You make it entertaining and you still take care of
    to keep it smart. I cant wait to read far more from you.

    This is really a tremendous website.

  4. I’m not that much of a online reader to be honest
    but your sites really nice, keep it up! I’ll go ahead and
    bookmark your site to come back later on. Cheers

  5. I’m amazed, I have to admit. Rarely do I come across a blog that’s both equally educative and
    interesting, and let me tell you, you’ve hit the nail on the
    head. The problem is something not enough men and women are speaking
    intelligently about. I’m very happy I found this during my search
    for something regarding this.

  6. Hi! Would you mind if I share your blog with my myspace group?

    There’s a lot of folks that I think would really appreciate your content.
    Please let me know. Thanks

  7. Just a smiling visitor here to share the love (:, btw outstanding style and design. “Justice is always violent to the party offending, for every man is innocent in his own eyes.” by Daniel Defoe.

  8. Whats up are using WordPress for your site platform?
    I’m new to the blog world but I’m trying to get started and set up my
    own. Do you need any coding expertise to make your own blog?
    Any help would be really appreciated!

  9. Wow, amazing blog layout! How long have you been blogging for?
    you made blogging look easy. The overall look of your site is wonderful, as well as the
    content!

  10. Hello, i believe that i saw you visited my web site so i got
    here to go back the desire?.I’m trying to in finding issues to improve my web site!I suppose
    its good enough to use a few of your concepts!!

  11. Hey There. I found your blog using msn. This is a really well written article.
    I will be sure to bookmark it and return to read more of your useful info.
    Thanks for the post. I’ll certainly comeback.

  12. Thanks for any other informative blog. The place else may I am getting that kind of info written in such a perfect approach? I have a challenge that I’m simply now running on, and I’ve been at the look out for such info.

Leave a Reply

Your email address will not be published. Required fields are marked *