题目传送门:http://codeforces.com/problemset/problem/708/B
《论何为血wa》
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> #define LL long long #define abs(x) ((x)>0?(x):-(x)) using namespace std; const int MAXN = 1000000+9; LL a00,a01,a10,a11,tag,n; char pat[MAXN]; inline LL read(){ char c=getchar(); LL 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 int solve(LL w) { w *= 2; LL tmp = sqrt(w); if (tmp*(tmp+1) != w) {tag++;return 0;} else return tmp+1; } int main(){ a00 = read(); a01 = read(); a10 = read(); a11 = read(); if (!a00 && !a11 && !a01 && !a10) cout<<0<<endl, exit(0); else if (a11 && !a00 && !a10 && !a01) { if(solve(a11)) { a11 = solve(a11); for (LL i=1;i<=a11;i++) pat[i] = '1'; cout<<pat+1; } else cout<<"Impossible"; } else if (!a11 && a00 && !a10 && !a01) { if(solve(a00)){ a00 = solve(a00); for (LL i=1;i<=a00;i++) pat[i] = '0'; cout<<pat+1; } else cout<<"Impossible"; } else { a00 = solve(a00); a11 = solve(a11); if (tag) cout<<"Impossible"; else if (a00*a11 != a01 + a10) cout<<"Impossible"; else { n = a00+a11; int l1 = a10/a00, l2 = a01/a00; if (l1*a00 < a10) pat[n-l2-(a10-l1*a00)] = '1'; if (l2*a00 < a01) pat[l1+(a01-l2*a00)+1] = '1'; for (int i=1;i<=l1;i++) pat[i] = '1'; for (int i=1;i<=l2;i++) pat[n-i+1] = '1'; for (int i=1;i<=n;i++) if (!pat[i]) pat[i] = '0'; printf("%s",pat+1); } } return 0; }
Somebody necessarily help to make significantly posts
I would state. This is the first time I frequented your website page
and up to now? I surprised with the research you made to create this actual submit incredible.
Magnificent job!
Having read this I believed it was rather informative.
I appreciate you finding the time and energy to put this information together.
I once again find myself personally spending a lot
of time both reading and leaving comments. But so what, it was still worth it!
Fine way of describing, and pleasant post to get data regarding
my presentation topic, which i am going to present
in academy.
I constantly spent my half an hour to read this web site’s posts all the time along with a mug of coffee.
Oh my goodness! Impressive article dude! Many thanks, However I am
having issues with your RSS. I don’t understand why I can’t subscribe to it.
Is there anybody having similar RSS problems? Anyone who knows the solution will you
kindly respond? Thanks!!
This is very interesting, You’re a very skilled blogger.
I have joined your feed and look forward to seeking more
of your great post. Also, I’ve shared your site in my social networks!
Currently it seems like Drupal is the best blogging platform available right now.
(from what I’ve read) Is that what you’re using on your blog?
What’s up, this weekend is good in support of me, because this time
i am reading this wonderful informative paragraph here at my house.
I do believe all of the ideas you have offered on your post.
They are very convincing and can certainly work.
Still, the posts are too quick for newbies. Could you please lengthen them a little from subsequent time?
Thank you for the post.
Hey There. I discovered your blog using msn. This is a very neatly written article.
I will be sure to bookmark it and return to learn more of your useful information. Thank you for the post.
I will certainly return.
This is my first time go to see at here and i am truly pleassant to read
all at alone place.
Thanks for one’s marvelous posting! I really enjoyed
reading it, you are a great author.I will be sure to
bookmark your blog and will eventually come back in the future.
I want to encourage you to definitely continue your great posts, have a nice
morning!
Thanks for sharing your thoughts on coconut oil. Regards
It is perfect time to make some plans for the future and it
is time to be happy. I’ve learn this submit and if I may I
desire to recommend you some fascinating
things or suggestions. Perhaps you could write subsequent articles relating to this article.
I want to read more things approximately it!
I haven?¦t checked in here for a while as I thought it was getting boring, but the last few posts are great quality so I guess I will add you back to my daily bloglist. You deserve it my friend 🙂
Hello! Do you know if they make any plugins to safeguard against hackers?
I’m kinda paranoid about losing everything I’ve worked hard
on. Any recommendations?
Now I am going away to do my breakfast, after having my breakfast coming
again to read additional news.
Thanks very interesting blog!
Ahaa, its pleasant conversation regarding this post
here at this weblog, I have read all that, so at
this time me also commenting at this place.
If some one wants expert view about blogging after that i propose him/her to pay a quick visit this webpage, Keep up the good work.
Thanks to my father who informed me regarding this website, this webpage is genuinely
amazing.
Hi there, You have done a fantastic job. I’ll definitely digg it and
personally recommend to my friends. I’m confident
they will be benefited from this site.
Hi there to all, the contents present at this web
page are in fact amazing for people knowledge, well, keep up
the good work fellows.
Someone essentially lend a hand to make severely posts
I’d state. That is the first time I frequented your web page and so
far? I surprised with the research you made to create this particular put up incredible.
Magnificent process!
Currently it looks like Drupal is the top blogging platform available right now.
(from what I’ve read) Is that what you’re using on your blog?
I was suggested this website by my cousin. I am not sure whether this post is written by
him as no one else know such detailed about my problem. You’re wonderful!
Thanks!
Fantastic blog! Do you have any hints for aspiring writers? I’m planning to start my own site soon but I’m a little lost on everything. Would you advise starting with a free platform like WordPress or go for a paid option? There are so many options out there that I’m completely confused .. Any ideas? Bless you!
I added a new list. As you’ll see it’s bigger than most of them. I hope you all have had a great week!
I like the helpful info you provide in your articles. I will bookmark your weblog and check again here regularly
Whats Going down i’m new to this, I stumbled upon this I’ve discovered It positively helpful and it has helped me out loads. I am hoping to give a contribution
This is the perfect webpage for everyone who hopes to find out about this
topic. You realize so much its almost tough to argue with you (not that I really will need
to…HaHa). You definitely put a brand new spin on a subject
that’s been discussed for years. Excellent stuff, just great!
I have been reading out some of your stories and i can state pretty nice stuff. I will definitely bookmark your site.
Appreciate you sharing, great blog.Really looking forward to read more. Great.
I truly appreciate this blog article.Much thanks again. Awesome.