题目传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2242
数据生成器:http://paste.ubuntu.com/22875643/
数据传送门:http://pan.baidu.com/s/1dE71QHr
这个题,做了一个下午+一个晚上,最后才发现是把”cannot”中间多加了一个‘a’
MD,老子好想杀人! (╯‵□′)╯︵┻━┻
题目本身很简单,就是快速幂+拓展欧几里得+BSGS
但网上的程序,多少有问题,反正我能搜出来的,我都可以叉掉
我这份代码问题应该比较少吧:
#include<cstdio> #include<iostream> #include<cmath> #include<cstring> #define LL long long using namespace std; const int MAXN = 100000; const double EPS = 1e-5; namespace Hash{ const int MOD = 99971; int head[MAXN],nxt[MAXN],val[MAXN],data[MAXN],T; inline void init(){ T = 0; memset(head,0,sizeof(head)); } inline void insert(int w, int d){ nxt[++T] = head[w%MOD]; val[T] = w; data[T] = d; head[w%MOD] = T; } inline int find(int w){ for (int i=head[w%MOD];i;i=nxt[i]) if (val[i] == w) return data[i]; return -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 int quick_pow(int a,int b,int c){ int ret = 1; while (b) { if (b & 1) ret = ((LL)ret * a) % c; a = (LL)a*a%c; b >>= 1; } return ret; } int GCD(int a, int b){return b?GCD(b,a%b):a;} void EX_GCD(int a, int b, int &x, int &y){ if (!b) x=1, y=0; else EX_GCD(b,a%b,y,x), y-=a/b*x; } inline int EX_GCD(int a, int b, int c) { int ret,tmp,gcd=GCD(a,b); if (c%gcd) return -1; else { EX_GCD(a/gcd,b/gcd,ret,tmp); ret = (((LL)c/gcd*ret) % b + b) % b; return ret; } } inline void solve(int a, int b, int c) { int ret = EX_GCD(a,c,b); if (~ret) printf("%d\n",ret); else printf("Orz, I cannot find x!\n"); } inline void BSGS(int a, int b, int c) { Hash::init(); a %= c; b %= c; if (!a && b > 1) {printf("Orz, I cannot find x!\n"); return;} int lim = int(ceil(sqrt(c))+EPS); for (int i=0,w=1;i<=lim;i++) { if (w == b) {printf("%d\n",i); return;} Hash::insert(w,i); w = ((LL)w*a) % c; } int w_ori = quick_pow(a,lim,c), rev_ori = quick_pow(w_ori,c-2,c); for (int i=1,w=w_ori,rev=rev_ori;i<=lim;i++) { int tmp = Hash::find(((LL)rev*b) % c); if (tmp > -1) {printf("%d\n",i*lim+tmp); return;} w = ((LL)w*w_ori) % c; rev = ((LL)rev*rev_ori) % c; } printf("Orz, I cannot find x!\n"); } int main(){ int T=read(),ty=read(); while (T--) { int a=read(), b=read(), c=read(); if (ty == 1) printf("%d\n",quick_pow(a,b,c)); else if (ty == 2) solve(a,b,c); else BSGS(a,b,c); } return 0; }
Enjoyed every bit of your article.Really thank you! Great.
Muchos Gracias for your post.Much thanks again. Great.
wow, awesome blog.Really looking forward to read more. Keep writing.
Really enjoyed this blog article.Much thanks again. Really Cool.
I think this is a real great blog post.Really thank you! Great.
I truly appreciate this article post.Really thank you! Much obliged.
I truly appreciate this blog.Much thanks again. Really Great.
I loved your article. Awesome.
Really appreciate you sharing this blog article.Really looking forward to read more. Cool.
Muchos Gracias for your article.Thanks Again. Really Cool.
wow, awesome blog post.Really looking forward to read more. Really Cool.
Hey, thanks for the article post.Really looking forward to read more. Will read on…
Very good blog.Really looking forward to read more. Much obliged.
I think this is a real great blog post. Cool.
Muchos Gracias for your post.Much thanks again. Keep writing.
Thanks for sharing, this is a fantastic post.Much thanks again. Cool.
I truly appreciate this article.Really thank you! Awesome.
Awesome article post.Really looking forward to read more. Will read on…
Awesome blog.Thanks Again. Cool.
Thanks for sharing, this is a fantastic blog article.Really looking forward to read more. Great.
I want to to thank you for this great read!! I absolutely loved every bit of it.
I have you book-marked to check out new stuff you post…
Hi are using WordPress for your site platform?
I’m new to the blog world but I’m trying to get started and create my
own. Do you need any html coding expertise to make your own blog?
Any help would be really appreciated!
Appreciate the recommendation. Let me try it out.
Really enjoyed this article post.Much thanks again. Awesome.
Fantastic blog post.Much thanks again. Cool.
I cannot thank you enough for the blog article.Thanks Again. Much obliged.
wow, awesome article. Will read on…
I think this is a real great blog article.Really thank you!
Thanks for sharing your thoughts about ps4 games.
Regards
Major thankies for the post. Much obliged.
Great article.Thanks Again. Really Great.
Aw, this was a very good post. Finding the time and actual effort to produce a top notch article… but what can I say… I procrastinate a whole lot and don’t manage
to get nearly anything done.
Great, thanks for sharing this blog. Want more.
Thank you for your article. Much obliged.
A round of applause for your blog article.Much thanks again.
When I initially commented I clicked the “Notify me when new comments are added” checkbox and
now each time a comment is added I get three e-mails
with the same comment. Is there any way you can remove people from that service?
Thanks a lot!
Link exchange is nothing else except it is only placing the other
person’s website link on your page at appropriate place and
other person will also do same for you.
I value the blog. Awesome.
Very informative article. Awesome.
Hey, thanks for the blog.Really looking forward to read more. Cool.
I really enjoy the blog article.Much thanks again. Much obliged.
Thanks for ones marvelous posting! I definitely enjoyed reading it, you can be a great author.
I will always bookmark your blog and will often come back later in life.
I want to encourage you to continue your great posts, have a nice
holiday weekend!
Wow, great article post.Thanks Again. Really Great.
Appreciate you sharing, great article.Thanks Again. Awesome.
Thanks a lot for the article.Really looking forward to read more. Will read on…
A round of applause for your blog article. Keep writing.
Yes! Finally someone writes about ps4 games.
Very informative article.Much thanks again. Want more.
Major thanks for the article.Thanks Again.
I really enjoy the blog article.Really looking forward to read more. Will read on…
I am so grateful for your article.Really thank you! Great.
Thanks for sharing, this is a fantastic article post.
Keep this going please, great job!
A big thank you for your blog post. Great.
Hey! Do you use Twitter? I’d like to follow you if that would be ok.
I’m undoubtedly enjoying your blog and look forward to new posts.
Im thankful for the post.Much thanks again. Awesome.
Hey very cool website!! Man .. Beautiful ..
Wonderful .. I will bookmark your blog and take the
feeds also? I’m glad to seek out so many helpful info
here within the post, we’d like work out more techniques in this regard, thank you for sharing.
. . . . .
Thank you for your article post.Much thanks again. Awesome.
I think the admin of this website is truly working hard for his web site, because here every data is quality based material.
Im obliged for the article.Really thank you! Will read on…
wow, awesome blog.Much thanks again. Want more.
That is a great tip particularly to those new to the blogosphere.
Short but very precise info… Appreciate your sharing this one.
A must read article!
Im thankful for the article.Really thank you! Really Cool.
Wow, great post. Want more.
Wonderful goods from you, man. I have remember your stuff previous to and you’re just extremely magnificent.
I really like what you have got here, certainly like what you’re
stating and the best way through which you are saying it.
You’re making it enjoyable and you continue to take care of
to keep it wise. I can not wait to read much more from you.
That is really a terrific website.
I really enjoy the blog post. Awesome.
Im thankful for the blog.Thanks Again. Much obliged.
Really appreciate you sharing this article.Really looking forward to read more. Really Great.
Thanks for the article post.Really thank you! Really Great.
Im obliged for the post. Really Great.
I really liked your article.Really thank you! Great.
Really enjoyed this blog article.Thanks Again. Want more.
I am so grateful for your blog.Much thanks again. Will read on…
Thank you for the auspicious writeup. It in fact was a amusement account it.
Look advanced to more added agreeable from you!
However, how can we communicate?
I was reading through some of your blog posts on this internet site and I think this internet site is real instructive! Continue posting.
I truly appreciate this article.Really thank you!
Looking forward to reading more. Great article.Really looking forward to read more. Will read on…
I think this is a real great article post.Really thank you! Keep writing.
Thank you for sharing your info. I truly appreciate your efforts and I will be waiting for your further write ups thanks once again.
Enjoyed every bit of your blog post. Awesome.
I truly appreciate this blog post.Thanks Again. Keep writing.
Really enjoyed this post.Thanks Again.
Im obliged for the article.Really looking forward to read more. Want more.
Very good blog.Much thanks again. Really Great.
Thanks for sharing, this is a fantastic blog article.Really thank you! Will read on…
Very neat blog article.Really thank you! Great.
I really liked your article post.Really looking forward to read more. Will read on…
I really like and appreciate your article. Fantastic.
I cannot thank you enough for the blog article. Awesome.
I am so grateful for your blog.Really looking forward to read more. Want more.
I appreciate you sharing this blog post.Really thank you! Keep writing.
Thank you for your post.Really thank you! Fantastic.
I really liked your post.Much thanks again. Keep writing.
Im grateful for the blog article.Really thank you! Really Cool.
Thanks so much for the article.Much thanks again. Will read on…
Im thankful for the blog.Thanks Again. Keep writing.
I truly appreciate this blog.Really thank you! Keep writing.
Muchos Gracias for your blog article. Really Great.
Great article! We are linking to this great content on our website.
Keep up the good writing.
Thanks so much for the blog. Want more.
Looking forward to reading more. Great post.Thanks Again. Cool.
I’m pretty pleased to uncover this page.
I want to to thank you for ones time just for this wonderful read!!
I definitely savored every little bit of it and i also have you bookmarked to see new information in your blog.
A big thank you for your blog article.Really thank you! Fantastic.
Really enjoyed this article.Much thanks again. Want more.
Fantastic blog article.Really thank you! Great.
Hey, thanks for the blog.Really looking forward to read more.
Muchos Gracias for your blog article.Thanks Again. Much obliged.
Wow, great article post.Thanks Again. Awesome.
Thanks-a-mundo for the post.Thanks Again. Great.
Fantastic blog article. Really Cool.
Thanks for sharing, this is a fantastic article.Thanks Again. Fantastic.
Great, thanks for sharing this article post.Much thanks again. Keep writing.
Thanks so much for the blog.Much thanks again. Really Cool.
Really informative post.Thanks Again. Keep writing.
I cannot thank you enough for the article post.Really thank you! Much obliged.
Very good article. Much obliged.
Major thankies for the blog.Thanks Again. Great.
Everyone loves what you guys tend to be up too. This type of clever work and reporting!
Keep up the terrific works guys I’ve you guys to my personal blogroll.
A round of applause for your article.Really looking forward to read more.
I loved your article.Thanks Again. Want more.
Just wish to say your article is as amazing. The clearness
on your publish is just excellent and i can think you are an expert
in this subject. Fine along with your permission let me to
seize your RSS feed to stay up to date with drawing close post.
Thank you one million and please continue the enjoyable work.
Thanks-a-mundo for the article post.Thanks Again. Awesome.
Hey, thanks for the blog post.Really looking forward to read more. Great.
This is one awesome blog post.Really looking forward to read more. Keep writing.
I appreciate you sharing this article.Really thank you! Really Cool.
A big thank you for your blog article. Much obliged.
Thanks a lot for the blog post.Really thank you! Cool.
Really informative blog post.Much thanks again. Really Cool.
A round of applause for your article post.Really looking forward to read more. Cool.
Great article post.Really thank you! Really Great.
I know this if off topic but I’m looking into starting my own weblog and was curious what all is
required 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 recommendations or advice would be greatly appreciated.
Thank you
Way cool! Some very valid points! I appreciate you penning this post and also the rest of the website is really good.
Thanks for the blog post.Really thank you! Really Great.
Appreciate you sharing, great blog post.Really thank you!
I value the article. Really Great.
This is one awesome post.Thanks Again. Really Great.
I value the article.Really looking forward to read more. Fantastic.
Really enjoyed this blog.Really looking forward to read more. Will read on…
I cannot thank you enough for the blog article.Really looking forward to read more. Really Cool.
Very good blog.Really looking forward to read more. Great.
This is one awesome blog post.Really thank you! Great.
Thanks for the blog article.Thanks Again. Will read on…
Hey, thanks for the article.Really looking forward to read more. Really Great.
Fantastic blog article.Really looking forward to read more. Cool.
I cannot thank you enough for the article. Really Cool.
A big thank you for your blog article. Will read on…
Thank you for your article. Much obliged.
Thanks a lot for the blog post.Really thank you! Much obliged.
I really like what you guys tend to be up too.
This sort of clever work and coverage! Keep up the very good works guys
I’ve added you guys to blogroll.
Awesome blog post. Really Cool.
We stumbled over here by a different page and thought I might as well
check things out. I like what I see so now i am following you.
Look forward to going over your web page for a second time.
I cannot thank you enough for the blog article.Really thank you! Want more.
I think this is a real great blog.Really looking forward to read more. Really Cool.
Enjoyed every bit of your post.Thanks Again. Much obliged.
Great blog post.Really thank you! Cool.
Hey, thanks for the article post.Really looking forward to read more. Great.
I really enjoy the post.Much thanks again.
Great blog. Cool.
Really informative blog.Much thanks again. Want more.
Very good article post.Much thanks again. Fantastic.
A round of applause for your blog article. Will read on…
Great, thanks for sharing this blog article.Really looking forward to read more. Cool.
Im obliged for the article.Thanks Again. Really Cool.
I value the article post.Much thanks again. Really Cool.
Very good blog post.Really looking forward to read more. Will read on…
Im thankful for the article.Really looking forward to read more. Really Cool.
Great article post.Really looking forward to read more. Great.
Very good blog.Really looking forward to read more. Really Great.
Yes! Finally someone writes about sling tv best package 2020.
Very good blog.Really thank you!
I cannot thank you enough for the blog article.Thanks Again. Fantastic.
wow, awesome blog post. Great.
This is one awesome blog post.Really looking forward to read more.
Looking forward to reading more. Great article.Thanks Again. Want more.
I value the article.Much thanks again. Will read on…
Thanks a lot for the post. Really Cool.
Can I just say what a reduction to seek out someone who actually knows what theyre talking about on the internet. You undoubtedly know how one can convey a difficulty to gentle and make it important. Extra individuals must read this and perceive this facet of the story. I cant consider youre no more popular since you undoubtedly have the gift.
Say, you got a nice blog article. Really Great.
I cannot thank you enough for the blog.Really thank you! Much obliged.
I truly appreciate this blog article.Really thank you! Cool.
Awesome blog article.Thanks Again. Cool.
Hey, thanks for the post.Much thanks again. Really Cool.
Thanks so much for the blog post.Thanks Again. Fantastic.
I value the blog article. Fantastic.
Im obliged for the blog post.Much thanks again. Great.
Appreciate you sharing, great blog post.Really thank you! Much obliged.
A big thank you for your blog article.Much thanks again. Fantastic.
Appreciate you sharing, great blog.Really thank you! Really Great.
A big thank you for your post.Really thank you!
Thank you for your blog post.Much thanks again. Keep writing.
Very informative blog. Cool.
Im thankful for the article post. Awesome.
Major thanks for the blog.Much thanks again. Fantastic.
I think this is a real great blog article.Thanks Again. Fantastic.
Great blog.Really thank you! Great.
Thanks for the article post.Really thank you! Want more.
Saved as a favorite, I really like your blog!|
Aw, this was an incredibly nice post. Finding the time and actual effort to create a top notch article… but what can I say… I put things off a lot and never manage to get nearly anything done.|
I value the blog post. Keep writing.
I think this is a real great article.Really looking forward to read more. Really Cool.
Article writing is also a fun, if you know afterward you can write or else it is complex to write.|
I truly appreciate this article.Much thanks again. Great.
Thanks a lot for the blog post.Much thanks again. Fantastic.
Yes! Finally something about keyword1.|
Appreciate you sharing, great blog article.Much thanks again. Keep writing.
Appreciate you sharing, great blog article.Really looking forward to read more. Awesome.
Thanks again for the article post.Really thank you! Really Cool.
When some one searches for his essential thing, so he/she needs to be available that in detail, so that thing is maintained over here.|
Thanks for sharing, this is a fantastic article post.Really looking forward to read more. Want more.
Wow, great blog post.Thanks Again. Awesome.
I really like and appreciate your article post.Really thank you! Fantastic.
Awesome blog.Thanks Again. Cool.
I’ve read some good stuff here. Certainly value bookmarking for revisiting. I surprise how much effort you put to make this type of excellent informative site.|
Thanks , I have recently been searching for info about this subject for a long time and yours is the greatest I’ve discovered so far. But, what concerning the bottom line? Are you positive about the supply?|
Im obliged for the article post.Thanks Again.
Thanks for sharing, this is a fantastic blog.Much thanks again. Want more.
Fantastic article.Thanks Again. Awesome.
Hey There. I found your blog using msn. This is an extremely well written article. I will make sure to bookmark it and come back to read more of your useful information. Thanks for the post. I will certainly return.|
I blog frequently and I genuinely thank you for your content. This article has really peaked my interest. I’m going to bookmark your site and keep checking for new details about once per week. I opted in for your Feed too.|
Please let me know if you’re looking for a article author for your weblog. You have some really great posts and I think I would be a good asset. If you ever want to take some of the load off, I’d absolutely love to write some material for your blog in exchange for a link back to mine. Please send me an e-mail if interested. Kudos!|
Major thanks for the blog.Much thanks again. Cool.
Great article.Really looking forward to read more. Much obliged.
This site was… how do I say it? Relevant!! Finally I have found something which helped me. Thanks!|
Really appreciate you sharing this article.Thanks Again. Keep writing.
I cannot thank you enough for the article post.Thanks Again.
It’s going to be end of mine day, however before ending I am reading this wonderful paragraph to improve my knowledge.|
Say, you got a nice blog.Really looking forward to read more. Really Great.
What’s Taking place i am new to this, I stumbled upon this I’ve found It positively helpful and it has helped me out loads. I am hoping to give a contribution & aid different users like its helped me. Good job.|
Im obliged for the article.Much thanks again. Great.
Great article post.Really thank you! Keep writing.
Im obliged for the blog article.Thanks Again. Fantastic.
Attractive portion of content. I simply stumbled upon your website and in accession capital to say that I acquire in fact enjoyed account your blog posts. Any way I will be subscribing to your augment and even I success you access persistently rapidly.|
Thanks again for the article. Will read on…
Major thankies for the article post.Really thank you! Awesome.
First of all I want to say wonderful blog! I had a quick question in which I’d like to ask if you do not mind. I was interested to know how you center yourself and clear your thoughts prior to writing. I have had trouble clearing my mind in getting my ideas out there. I do take pleasure in writing however it just seems like the first 10 to 15 minutes are lost simply just trying to figure out how to begin. Any suggestions or tips? Cheers!|
We’re a group of volunteers and starting a new scheme in our community. Your site provided us with valuable info to work on. You have done an impressive job and our whole community will be thankful to you.|