比赛 |
防止浮躁的小练习v0.6 |
评测结果 |
AAAAAAAAAA |
题目名称 |
同余方程 |
最终得分 |
100 |
用户昵称 |
kito |
运行时间 |
0.023 s |
代码语言 |
C++ |
内存使用 |
0.26 MiB |
提交时间 |
2016-10-20 16:33:31 |
显示代码纯文本
- #include<cstdio>
- using namespace std;
- #define fcl fclose(stdin); fclose(stdout); return 0
- #define SUBMIT 2333
- typedef long long LL;
- LL A,B;
- void ExGcd(LL a,LL b,LL& x,LL& y){
- if(b==0){
- x=1; y=0;
- return;
- }
- ExGcd(b,a%b,x,y);
- LL t=x;
- x=y; y=t-(a/b)*y;
- }
-
- int main(){
- #ifdef SUBMIT
- freopen("mod.in","r",stdin);
- freopen("mod.out","w",stdout);
- #endif
- scanf("%lld%lld",&A,&B);
- LL x,y;
- ExGcd(A,B,x,y);
- x%=B;
- x=(x+B)%B;
- printf("%lld",x);
- #ifndef SUBMIT
- getchar(); getchar();
- #endif
- fcl;
- }