【SOJ 256】[NOIP2012] 同余方程

题目传送门:http://oi.cdshishi.net:8080/Problem/256
离线版题目:http://paste.ubuntu.com/17895904/

求逆元的板题,顺便补了exGCD,么么哒!

#include<iostream>
#include<cstdio>
using namespace std;

inline void exGCD(int a, int b, int &x, int &y){
	if (b==0) {x=1;y=0;}
	else {exGCD(b,a%b,y,x);y-=(a/b)*x;}
}

int main(){
	int a,b,x,y;
	scanf("%d%d",&a,&b);
	exGCD(a,b,x,y);
	printf("%d\n",((x%b)+b)%b);
	return 0;
} 

18 thoughts to “【SOJ 256】[NOIP2012] 同余方程”

  1. Hi there just wanted to give you a quick heads up.

    The words in your article seem to be running off the screen in Internet
    explorer. I’m not sure if this is a formatting issue or something to do with internet browser compatibility but I thought
    I’d post to let you know. The style and design look great though!
    Hope you get the issue fixed soon. Kudos

  2. It’s perfect time to make some plans for the
    future and it is time to be happy. I’ve read this post and if I could I want to suggest you some
    interesting things or advice. Maybe you can write next articles referring to this article.
    I wish to read even more things about it!

  3. 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?

  4. Heya i’m for the first time here. I came across this board and I in finding It truly helpful & it helped me out a lot.

    I am hoping to provide something again and help others such
    as you helped me.

  5. I used to be more than happy to seek out this web-site.I needed to thanks to your time for this excellent read!! I definitely enjoying every little bit of it and I’ve you bookmarked to take a look at new stuff you blog post.

  6. Its like you read my mind! You seem to know so much about this,
    like you wrote the book in it or something.
    I think that you can do with some pics to drive the message home a
    little bit, but other than that, this is great blog.
    A great read. I’ll definitely be back.

  7. I’m really inspired with your writing talents and also with the structure for your blog.

    Is this a paid subject or did you customize it yourself?
    Anyway stay up the nice high quality writing, it’s rare to peer a nice weblog like this one these days..

Leave a Reply

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