| 比赛 | 20160303 | 评测结果 | AAAAAAAAAA |
|---|---|---|---|
| 题目名称 | 同余方程 | 最终得分 | 100 |
| 用户昵称 | Fancy | 运行时间 | 0.002 s |
| 代码语言 | C++ | 内存使用 | 0.29 MiB |
| 提交时间 | 2016-03-03 19:19:10 | ||
#include<cstdio>
#include<cmath>
using namespace std;
int a,b,x,y;
void exgcd(int a,int b,int &x,int &y)
{
if(!b) { x=1; y=0; }
else { exgcd(b,a%b,y,x); y-=x*(a/b); }
}
int main()
{
freopen("mod.in","r",stdin);
freopen("mod.out","w",stdout);
scanf("%d%d",&a,&b);
exgcd(a,b,x,y);
x%=b; while(x<=0) x+=b;
printf("%d",x);
}