【BZOJ 1005】[HNOI2008] 明明的烦恼

题目传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1005
数据生成器:http://paste.ubuntu.com/23338303/

这题和BZOJ_1211几乎一毛一样
唯一的区别:这题要写高精 qwq
于是果断弃疗,扔一份不带高精的代码:

#include<bits/stdc++.h>
#define LL long long
using namespace std;

const int N = 1000+9;
const int MX = 1000;

int C[N][N],res,n,emp;
LL vout=1; 

inline int read(){
	char c=getchar(); int ret=0,f=1;
	while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
	while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();}
	return ret*f;
}

inline void prework(){
	C[0][0] = C[1][1] = C[0][1] = 1;
	for (int j=1;j<=MX;j++) {
		C[0][j] = 1;
		for (int i=1;i<=j;i++) {
			C[i][j] = C[i][j-1] + C[i-1][j-1];
		}
	}
}

int main(){
	if ((n=read()) == 1) {
		if (!read()) puts("1");
		else puts("1");
	} else if (n == 2) {
		if (read() == 1 && read() == 1) puts("1");
		else puts("0");
	} else {
		prework(); emp = n - 2;
		for (int i=1,tmp;i<=n;i++) {
			if ((tmp=read()) == -1) {
				res++;
			} else {
				vout *= C[tmp-1][emp];
				emp -= tmp - 1;
			}
		}
		if (emp < 0) puts("0");
		else {
			for (int i=1;i<=emp;i++) {
				vout *= res;
			}
			cout<<vout;
		}
	}
	return 0;
}

195 thoughts to “【BZOJ 1005】[HNOI2008] 明明的烦恼”

  1. Heya i am for the first time here. I found this board and I find It truly helpful & it helped me out a lot.
    I am hoping to provide something back and help others like you aided me.

  2. My developer is trying to convince me to move to .net from PHP.

    I have always disliked the idea because of the costs.
    But he’s tryiong none the less. I’ve been using Movable-type on various websites for about a year and am worried
    about switching to another platform. I have heard fantastic things about
    blogengine.net. Is there a way I can transfer all my wordpress posts into it?
    Any help would be greatly appreciated!

  3. Today, I went to the beach front with my kids. I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She put the shell to her
    ear and screamed. There was a hermit crab inside and it pinched her ear.
    She never wants to go back! LoL I know this is totally off topic but I had to tell someone!

  4. I know this web page provides quality depending content and additional material, is there
    any other web site which gives such information in quality?

  5. Simply desire to say your article is as astounding.
    The clarity on your publish is simply cool and that
    i could think you are a professional in this subject. Fine along with your permission allow me
    to clutch your RSS feed to keep updated with drawing close post.

    Thanks a million and please keep up the enjoyable work.

  6. Hello There. I found your blog using msn. That is an extremely smartly written article.
    I will be sure to bookmark it and come back to read extra of your useful information.
    Thanks for the post. I will certainly comeback.

  7. Good day! I know this is kind of off topic but I was wondering which blog platform are you using for this site?
    I’m getting sick and tired of WordPress because I’ve had issues with hackers and I’m
    looking at options for another platform. I would be awesome if you could point me in the direction of a good platform.

  8. Heya just wanted to give you a brief heads up and let you know a few of the pictures aren’t loading properly.
    I’m not sure why but I think its a linking issue. I’ve tried it in two different browsers and both show the same outcome.

  9. “4 Songs for the Club” Is a 4 song CD-EP from B-Rock, For Dj’s and Bars and Dance clubs ..”Dance”Features Rockman doing the electronic Vocals on the Chorus. A hand clapping song to get people on tha dance floor ….”Mix It With Tha Water”. Features B-Rocks Team member Pif .. Tha song is an urban street tale with a great Trap Beat….”I Like It Straight” is Bound to be a New Club/ Bar Anthem for the DJ’s to get the crowds up on their feet and to get another drink..LOL…and “Crack Them bottle (Get Fucked Up)” well that’s a story that all party goers live on the weekend! … 4 Dance Hits 4 tha Club.. a great EP for any DJ to have

  10. It’s awesome to go to see this website and reading the views
    of all friends regarding this paragraph, while I
    am also eager of getting knowledge.

  11. When some one searches for his essential thing, therefore
    he/she wishes to be available that in detail, so that
    thing is maintained over here.

  12. Hello there! Do you know if they make any plugins to protect against hackers?
    I’m kinda paranoid about losing everything I’ve
    worked hard on. Any tips?

  13. Hey would you mind sharing which blog platform you’re using?

    I’m looking to start my own blog in the near future but I’m having a hard time making a decision between BlogEngine/Wordpress/B2evolution and
    Drupal. The reason I ask is because your design and style seems different
    then most blogs and I’m looking for something unique.
    P.S Apologies for getting off-topic but I had to ask!

  14. Having read this I believed it was very enlightening.

    I appreciate you taking the time and effort to put this
    content together. I once again find myself spending a lot of time both reading and leaving comments.

    But so what, it was still worth it!

  15. Hey there, I think your website might be having browser
    compatibility issues. When I look at your blog in Firefox, it looks fine but when opening
    in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads
    up! Other then that, fantastic blog!

  16. Wonderful blog! I found it while browsing on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Appreciate it

Leave a Reply

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