记录编号 190404 评测结果 AAAAAAAAAA
题目名称 [NOIP 2012]同余方程 最终得分 100
用户昵称 Gravatar啊吧啦吧啦吧 是否通过 通过
代码语言 C++ 运行时间 0.001 s
提交时间 2015-10-03 08:21:15 内存使用 0.28 MiB
显示代码纯文本
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. ifstream fin("mod.in");
  7. ofstream fout("mod.out");
  8. int a, b, c = 1, x, y, gbd, gcd(int, int);
  9. #define cin fin
  10. #define cout fout
  11.  
  12. main()
  13. {
  14. cin >> a >> b;
  15. gbd = a / gcd(a, b) * b;
  16. x = (x + b) % b;
  17. cout << x;
  18. }
  19.  
  20. int gcd(int a, int b)
  21. {
  22. if (b == 0){
  23. y = 0;
  24. x = c / a;
  25. return a;
  26. }
  27. int g = gcd(b, a % b), xx, yy;
  28. xx = y;
  29. yy = x - y * (a / b);
  30. x = xx;
  31. y = yy;
  32. return g;
  33. }