这是我见过的,最强的输入输出库
没有之一
namespace fastIO{ #define BUF_SIZE 100000 #define OUT_SIZE 100000 #define ll long long //fread->read bool IOerror=0; inline char nc(){ static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE; if (p1==pend){ p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin); if (pend==p1){IOerror=1;return -1;} //{printf("IO error!\n");system("pause");for (;;);exit(0);} } return *p1++; } inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';} inline void read(int &x){ bool sign=0; char ch=nc(); x=0; for (;blank(ch);ch=nc()); if (IOerror)return; if (ch=='-')sign=1,ch=nc(); for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0'; if (sign)x=-x; } inline void read(ll &x){ bool sign=0; char ch=nc(); x=0; for (;blank(ch);ch=nc()); if (IOerror)return; if (ch=='-')sign=1,ch=nc(); for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0'; if (sign)x=-x; } inline void read(double &x){ bool sign=0; char ch=nc(); x=0; for (;blank(ch);ch=nc()); if (IOerror)return; if (ch=='-')sign=1,ch=nc(); for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0'; if (ch=='.'){ double tmp=1; ch=nc(); for (;ch>='0'&&ch<='9';ch=nc())tmp/=10.0,x+=tmp*(ch-'0'); } if (sign)x=-x; } inline void read(char *s){ char ch=nc(); for (;blank(ch);ch=nc()); if (IOerror)return; for (;!blank(ch)&&!IOerror;ch=nc())*s++=ch; *s=0; } inline void read(char &c){ for (c=nc();blank(c);c=nc()); if (IOerror){c=-1;return;} } //getchar->read inline void read1(int &x){ char ch;int bo=0;x=0; for (ch=getchar();ch<'0'||ch>'9';ch=getchar())if (ch=='-')bo=1; for (;ch>='0'&&ch<='9';x=x*10+ch-'0',ch=getchar()); if (bo)x=-x; } inline void read1(ll &x){ char ch;int bo=0;x=0; for (ch=getchar();ch<'0'||ch>'9';ch=getchar())if (ch=='-')bo=1; for (;ch>='0'&&ch<='9';x=x*10+ch-'0',ch=getchar()); if (bo)x=-x; } inline void read1(double &x){ char ch;int bo=0;x=0; for (ch=getchar();ch<'0'||ch>'9';ch=getchar())if (ch=='-')bo=1; for (;ch>='0'&&ch<='9';x=x*10+ch-'0',ch=getchar()); if (ch=='.'){ double tmp=1; for (ch=getchar();ch>='0'&&ch<='9';tmp/=10.0,x+=tmp*(ch-'0'),ch=getchar()); } if (bo)x=-x; } inline void read1(char *s){ char ch=getchar(); for (;blank(ch);ch=getchar()); for (;!blank(ch);ch=getchar())*s++=ch; *s=0; } inline void read1(char &c){for (c=getchar();blank(c);c=getchar());} //scanf->read inline void read2(int &x){scanf("%d",&x);} inline void read2(ll &x){ #ifdef _WIN32 scanf("%I64d",&x); #else #ifdef __linux scanf("%lld",&x); #else puts("error:can't recognize the system!"); #endif #endif } inline void read2(double &x){scanf("%lf",&x);} inline void read2(char *s){scanf("%s",s);} inline void read2(char &c){scanf(" %c",&c);} inline void readln2(char *s){gets(s);} //fwrite->write struct Ostream_fwrite{ char *buf,*p1,*pend; Ostream_fwrite(){buf=new char[BUF_SIZE];p1=buf;pend=buf+BUF_SIZE;} void out(char ch){ if (p1==pend){ fwrite(buf,1,BUF_SIZE,stdout);p1=buf; } *p1++=ch; } void print(int x){ static char s[15],*s1;s1=s; if (!x)*s1++='0';if (x<0)out('-'),x=-x; while(x)*s1++=x%10+'0',x/=10; while(s1--!=s)out(*s1); } void println(int x){ static char s[15],*s1;s1=s; if (!x)*s1++='0';if (x<0)out('-'),x=-x; while(x)*s1++=x%10+'0',x/=10; while(s1--!=s)out(*s1); out('\n'); } void print(ll x){ static char s[25],*s1;s1=s; if (!x)*s1++='0';if (x<0)out('-'),x=-x; while(x)*s1++=x%10+'0',x/=10; while(s1--!=s)out(*s1); } void println(ll x){ static char s[25],*s1;s1=s; if (!x)*s1++='0';if (x<0)out('-'),x=-x; while(x)*s1++=x%10+'0',x/=10; while(s1--!=s)out(*s1); out('\n'); } void print(double x,int y){ static ll mul[]={1,10,100,1000,10000,100000,1000000,10000000,100000000, 1000000000,10000000000LL,100000000000LL,1000000000000LL,10000000000000LL, 100000000000000LL,1000000000000000LL,10000000000000000LL,100000000000000000LL}; if (x<-1e-12)out('-'),x=-x;x*=mul[y]; ll x1=(ll)floor(x); if (x-floor(x)>=0.5)++x1; ll x2=x1/mul[y],x3=x1-x2*mul[y]; print(x2); if (y>0){out('.'); for (size_t i=1;i<y&&x3*mul[i]<mul[y];out('0'),++i); print(x3);} } void println(double x,int y){print(x,y);out('\n');} void print(char *s){while (*s)out(*s++);} void println(char *s){while (*s)out(*s++);out('\n');} void flush(){if (p1!=buf){fwrite(buf,1,p1-buf,stdout);p1=buf;}} ~Ostream_fwrite(){flush();} }Ostream; inline void print(int x){Ostream.print(x);} inline void println(int x){Ostream.println(x);} inline void print(char x){Ostream.out(x);} inline void println(char x){Ostream.out(x);Ostream.out('\n');} inline void print(ll x){Ostream.print(x);} inline void println(ll x){Ostream.println(x);} inline void print(double x,int y){Ostream.print(x,y);} inline void println(double x,int y){Ostream.println(x,y);} inline void print(char *s){Ostream.print(s);} inline void println(char *s){Ostream.println(s);} inline void println(){Ostream.out('\n');} inline void flush(){Ostream.flush();} //puts->write char Out[OUT_SIZE],*o=Out; inline void print1(int x){ static char buf[15]; char *p1=buf;if (!x)*p1++='0';if (x<0)*o++='-',x=-x; while(x)*p1++=x%10+'0',x/=10; while(p1--!=buf)*o++=*p1; } inline void println1(int x){print1(x);*o++='\n';} inline void print1(ll x){ static char buf[25]; char *p1=buf;if (!x)*p1++='0';if (x<0)*o++='-',x=-x; while(x)*p1++=x%10+'0',x/=10; while(p1--!=buf)*o++=*p1; } inline void println1(ll x){print1(x);*o++='\n';} inline void print1(char c){*o++=c;} inline void println1(char c){*o++=c;*o++='\n';} inline void print1(char *s){while (*s)*o++=*s++;} inline void println1(char *s){print1(s);*o++='\n';} inline void println1(){*o++='\n';} inline void flush1(){if (o!=Out){if (*(o-1)=='\n')*--o=0;puts(Out);}} struct puts_write{ ~puts_write(){flush1();} }_puts; inline void print2(int x){printf("%d",x);} inline void println2(int x){printf("%d\n",x);} inline void print2(char x){printf("%c",x);} inline void println2(char x){printf("%c\n",x);} inline void print2(ll x){ #ifdef _WIN32 printf("%I64d",x); #else #ifdef __linux printf("%lld",x); #else puts("error:can't recognize the system!"); #endif #endif } inline void println2(ll x){print2(x);printf("\n");} inline void println2(){printf("\n");} #undef ll #undef OUT_SIZE #undef BUF_SIZE };
看了这份代码以后,我觉得一切语言都是苍白的
—————————— UPD 2017.7.5 ——————————
日常卡常用的话,用下面这份代码就好
inline char Read(){ static const int BUF_SIZE = 1000000; static char buf[BUF_SIZE], *p1 = 0, *p2 = 0; if (p1 == p2){ p2 = (p1 = buf) + fread(buf, 1, BUF_SIZE, stdin); } return p1 == p2? -1: *p1++; } inline int read() { char c = Read(); int ret = 0, f = 1; for (; c < '0' || c > '9'; f = c == '-'? -1: 1, c = Read()); for (; '0' <= c && c <= '9'; ret = ret * 10 + c - '0', c = Read()); return ret * f; }
Hey would you mind letting me know which web host you’re working with?
I’ve loaded your blog in 3 different web browsers and I must say this blog loads
a lot quicker then most. Can you suggest a good web hosting
provider at a reasonable price? Thanks, I appreciate it!
Greetings! Quick question that’s completely off topic.
Do you know how to make your site mobile friendly? My web site looks weird
when browsing from my iphone4. I’m trying to find a template or plugin that might be able to correct this problem.
If you have any suggestions, please share. Cheers!
A fascinating discussion is definitely worth comment.
I do think that you need to write more on this subject, it may not be a taboo subject but typically people do not speak about such
issues. To the next! Kind regards!!
Hey there! I’m at work browsing your blog from my new iphone!
Just wanted to say I love reading your blog and look forward to all your posts!
Keep up the superb work!
I read this post fully about the comparison of latest and preceding technologies,
it’s awesome article.
Wow, incredible blog layout! How long have you been blogging for?
you make blogging look easy. The total look of your web
site is magnificent, let alone the content!
Hi there, I check your blog on a regular basis. Your story-telling style is awesome, keep it up!
Hi there! I’m at work surfing around your blog from my new
apple iphone! Just wanted to say I love reading your blog and
look forward to all your posts! Carry on the great work!
Thanks for sharing such a nice opinion, piece of writing is pleasant, thats why i have read it entirely
I know this if off topic but I’m looking into starting my own weblog and was
curious what all is required to get setup?
I’m assuming having a blog like yours would cost a pretty penny?
I’m not very internet savvy so I’m not 100% sure. Any recommendations or
advice would be greatly appreciated. Kudos
Very nice post. I simply stumbled upon your blog and wished to
say that I have really enjoyed browsing your weblog posts.
In any case I will be subscribing on your rss feed
and I hope you write once more very soon!
My coder is trying to convince me to move to .net from PHP.
I have always disliked the idea because of the expenses.
But he’s tryiong none the less. I’ve been using WordPress on various websites for about a
year and am nervous about switching to another platform.
I have heard good things about blogengine.net. Is there
a way I can transfer all my wordpress posts into it? Any kind of help would be really appreciated!
I am now not certain where you are getting your information, however great
topic. I needs to spend some time learning more or understanding more.
Thank you for fantastic info I was in search of
this information for my mission.
Hi to every body, it’s my first pay a quick visit of this blog;
this website contains remarkable and in fact excellent stuff in support of readers.
A fascinating discussion is definitely worth
comment. I think that you need to write more about this
subject matter, it may not be a taboo subject but generally people
don’t discuss such subjects. To the next! All the best!!
I was recommended this blog via my cousin. I’m no longer positive whether or not this post is written by means of him
as nobody else recognise such detailed approximately
my problem. You are amazing! Thank you!
Every weekend i used to go to see this website, because i want enjoyment, since this
this web page conations really nice funny stuff too.
Hi there friends, how is all, and what you wish for to say concerning this paragraph, in my view its actually awesome in support of me.
Its such as you learn my thoughts! You appear to know so much about this,
such as you wrote the e book in it or something.
I think that you could do with some % to force the message house
a bit, however other than that, this is fantastic blog.
An excellent read. I’ll certainly be back.
I am regular visitor, how are you everybody? This paragraph
posted at this website is really pleasant.
I visited many websites but the audio feature for audio songs
current at this site is really excellent.
My brother recommended I may like this website.
He was once entirely right. This post actually made my day.
You cann’t consider simply how so much time I had spent for this info!
Thank you! pof natalielise
It’s going to be finish of mine day, except before end I am reading this fantastic piece of writing
to increase my knowledge.
I feel that is one of the most significant information for
me. And i am glad reading your article. But want to commentary on some normal issues, The web site style is
ideal, the articles is actually excellent :
D. Just right process, cheers
I am in fact grateful to the owner of this website who has shared
this great piece of writing at here.
For the reason that the admin of this website is working, no doubt very soon it will be renowned,
due to its feature contents. natalielise pof
It’s amazing to pay a visit this web site and reading the views of all colleagues regarding this post, while I am also eager
of getting knowledge.
Aw, this was a very nice post. Finding the time and actual effort to
create a very good article… but what can I say… I procrastinate
a whole lot and never manage to get anything done.
Good day! This post couldn’t be written any better!
Reading through this post reminds me of my old room mate!
He always kept talking about this. I will forward this post to
him. Fairly certain he will have a good read. Thanks
for sharing!
You could certainly see your skills in the work you write.
The arena hopes for more passionate writers such as you who are not
afraid to mention how they believe. All the time go after your
heart.
Excellent blog here! Also your site loads up very fast!
What host are you using? Can I get your affiliate
link to your host? I wish my website loaded up as fast
as yours lol
I’m not sure the place you’re getting your info, but great topic.
I needs to spend a while learning much more or working out more.
Thank you for fantastic info I was looking for this information for my mission.
I was suggested this blog by means of my cousin.
I’m no longer certain whether this post is written by him as
nobody else recognise such particular approximately my difficulty.
You are incredible! Thanks!
Wonderful post however , I was wanting to know if you could
write a litte more on this topic? I’d be very thankful if you could elaborate a little bit more.
Appreciate it!
Amazing! Its really remarkable post, I have got much clear idea concerning from this paragraph.
You’re so cool! I do not think I’ve truly read through something like that before.
So wonderful to discover someone with genuine thoughts on this topic.
Seriously.. many thanks for starting this up. This web site is
something that is required on the internet, someone with a bit of
originality!
It is really a great and useful piece of information. I am satisfied that you shared this useful information with us.
Please keep us up to date like this. Thank you for sharing.
Wonderful beat ! I would like to apprentice while you amend your site, how can i subscribe
for a blog website? The account aided me a acceptable deal.
I had been tiny bit acquainted of this your broadcast
offered bright clear concept
Hi! Would you mind if I share your blog with my zynga group?
There’s a lot of people that I think would really appreciate your
content. Please let me know. Cheers
Heya i am for the first time here. I found this board and I find
It truly useful & it helped me out much. I am hoping to
offer something back and aid others like you helped me.
I know this if off topic but I’m looking into starting my own blog and was wondering what all is
needed to get setup? I’m assuming having a blog like yours would cost a pretty penny?
I’m not very web savvy so I’m not 100% sure.
Any recommendations or advice would be greatly appreciated.
Appreciate it
I think this is among the most important information for me.
And i am glad reading your article. But wanna remark on few general things, The website style is perfect,
the articles is really great : D. Good job, cheers
Magnificent goods from you, man. I’ve understand your stuff previous
to and you’re just extremely magnificent. I really like what you’ve acquired here,
really like what you are saying and the way in which you say
it. You make it entertaining and you still care for to keep it sensible.
I cant wait to read far more from you. This is
actually a wonderful website.
Everything is very open with a precise clarification of
the issues. It was definitely informative.
Your site is extremely helpful. Thank you for sharing!
I loved as much as you’ll receive carried out right here.
The sketch is tasteful, your authored subject matter stylish.
nonetheless, you command get bought an shakiness over that you wish be delivering the following.
unwell unquestionably come more formerly again as exactly the
same nearly a lot often inside case you shield this hike.
I’m now not positive the place you are getting your information, however great topic.
I needs to spend some time finding out much more or figuring out more.
Thank you for fantastic info I was in search of this info for my mission.
I loved as much as you’ll receive carried
out right here. The sketch is tasteful, your authored subject matter
stylish. nonetheless, you command get got an shakiness over
that you wish be delivering the following. unwell unquestionably come further formerly again as exactly the
same nearly a lot often inside case you shield
this hike.
Magnificent beat ! I wish to apprentice while you amend your website, how could
i subscribe for a weblog website? The account helped
me a applicable deal. I have been tiny bit acquainted of
this your broadcast provided shiny clear idea
Heya i am for the first time here. I came across this board and
I find It truly useful & it helped me out a lot. I hope to give something back and aid others like you helped me.
Excellent post. I used to be checking constantly this blog and I am
inspired! Extremely useful info particularly the remaining part 🙂 I care for such information a
lot. I used to be looking for this certain information for a long time.
Thanks and good luck.
Hi, yeah this piece of writing is genuinely pleasant and I have learned lot of things
from it on the topic of blogging. thanks.
I have been browsing online more than three hours lately, yet I by no means found
any attention-grabbing article like yours.
It’s beautiful value sufficient for me. In my opinion, if
all site owners and bloggers made just right content material as you probably did, the internet will be a lot more helpful than ever before.
A round of applause for your article post.Much thanks again. Keep writing.
Amazing! Its truly remarkable piece of writing, I have got much clear idea about from
this piece of writing.
Good post! We will be linking to this particularly
great article on our site. Keep up the good writing.
of course like your web site but you need to check the
spelling on several of your posts. A number of them are
rife with spelling issues and I to find it very
troublesome to inform the reality nevertheless I
will surely come again again.
Hey very interesting blog!
Hi there! I just wanted to ask if you ever have any issues with hackers?
My last blog (wordpress) was hacked and I ended up losing months of hard work due to no back up.
Do you have any methods to stop hackers?
Hi there, after reading this awesome piece of writing
i am too delighted to share my familiarity here with mates.
Yes! Finally someone writes about quest bars cheap.
Hi i am kavin, its my first occasion to commenting
anyplace, when i read this post i thought i could also make comment due to this good post.
Hi my loved one! I want to say that this post is
amazing, nice written and come with almost all significant infos.
I would like to look more posts like this .
Your means of telling all in this piece of writing is genuinely pleasant, all be
capable of effortlessly understand it, Thanks a lot.
Hi there! Someone in my Myspace group shared this site with
us so I came to look it over. I’m definitely enjoying the information. I’m book-marking and will be tweeting this to my followers!
Fantastic blog and superb design.
Please let me know if you’re looking for a article writer for your weblog.
You have some really good posts and I believe I would be
a good asset. If you ever want to take some of the load off,
I’d really like to write some articles for your blog in exchange for a link back to mine.
Please send me an e-mail if interested. Cheers!
Thanks designed for sharing such a nice opinion, paragraph is good, thats why
i have read it completely
This paragraph is genuinely a fastidious one it assists
new the web users, who are wishing for blogging.
What’s up, after reading this amazing paragraph i am
too happy to share my know-how here with mates.
I have been exploring for a little for any high quality articles or blog
posts in this sort of area . Exploring in Yahoo I eventually stumbled upon this website.
Reading this information So i am satisfied to express that
I have a very good uncanny feeling I found out just what I needed.
I so much undoubtedly will make sure to do not put out of your
mind this web site and give it a glance regularly.
magnificent post, very informative. I wonder why the other
experts of this sector do not understand this. You must proceed your
writing. I am confident, you have a huge readers’ base already!
Hello, I enjoy reading all of your article. I like to write a little
comment to support you.
I know this if off topic but I’m looking into starting my own blog and was wondering what all is needed to get set
up? I’m assuming having a blog like yours would cost a pretty penny?
I’m not very internet savvy so I’m not 100% positive.
Any suggestions or advice would be greatly appreciated.
Appreciate it
Way cool! Some extremely valid points! I appreciate you penning this article and the rest of the website
is also really good.
It’s truly very complicated in this full of activity life to listen news on Television, so I
simply use web for that reason, and take the latest information.
Hi there! This post couldn’t be written any better! Reading through this post reminds me of my previous room mate! He always kept talking about this. I will forward this article to him. Pretty sure he will have a good read. Thank you for sharing!
Excellent post. I was checking constantly this weblog and I’m impressed!
Very useful information specially the ultimate phase :
) I handle such info a lot. I used to be seeking this particular info for a
very long time. Thank you and good luck.
I like the helpful info you provide in your articles.
I’ll bookmark your weblog and check again here frequently.
I’m quite certain I’ll learn a lot of new stuff right here!
Best of luck for the next!
I am in fact grateful to the holder of this web page who has shared this impressive post at here.
Fantastic website. Plenty of helpful information here.
I am sending it to some pals ans also sharing
in delicious. And naturally, thanks to your sweat!
Hello my loved one! I wish to say that this post is
amazing, nice written and come with almost all important infos.
I’d like to look more posts like this .
This piece of writing provides clear idea in favor of the new viewers
of blogging, that in fact how to do blogging and site-building.
Pretty nice post. I simply stumbled upon your blog and wished to say that I have truly loved browsing your blog
posts. After all I will be subscribing for your feed and I’m hoping you write again very soon!
What’s up to every body, it’s my first pay a visit of
this web site; this weblog includes remarkable and actually fine data in favor of
readers.
For newest news you have to pay a quick visit internet and on web I
found this web page as a best website for most recent updates.
Hi, I log on to your blog on a regular basis. Your humoristic style is awesome,
keep it up!
Amazing! Its in fact remarkable post, I have got much clear idea on the topic of from this article.
Hi there friends, nice piece of writing and
nice arguments commented here, I am actually enjoying by these.
I regard something truly special in this website.
Say, you got a nice article. Cool.