比赛 20160303 评测结果 AAAAAAAAAA
题目名称 同余方程 最终得分 100
用户昵称 mikumikumi 运行时间 0.002 s
代码语言 C++ 内存使用 0.31 MiB
提交时间 2016-03-03 19:09:24
显示代码纯文本
  1. #include<cstdio>
  2. #include<iostream>
  3. using namespace std;
  4. typedef long long LL;
  5. LL A,B;
  6. class miku
  7. {
  8. public:
  9. LL x,y;
  10. };
  11. miku gcd(LL x,LL y)
  12. {
  13. miku tem;
  14. if(y==0)
  15. {
  16. tem.x=1;tem.y=0;
  17. }
  18. else
  19. {
  20. miku before=gcd(y,x%y);
  21. tem.x=before.y;
  22. tem.y=before.x-(x/y)*before.y;
  23. }
  24. return tem;
  25. }
  26. int main()
  27. {
  28. freopen("mod.in","r",stdin);
  29. freopen("mod.out","w",stdout);
  30. cin>>A>>B;
  31. miku ans=gcd(A,B);
  32. ans.x=(ans.x+B)%B;
  33. cout<<ans.x;
  34. return 0;
  35. }