记录编号 |
190404 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOIP 2012]同余方程 |
最终得分 |
100 |
用户昵称 |
啊吧啦吧啦吧 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.001 s |
提交时间 |
2015-10-03 08:21:15 |
内存使用 |
0.28 MiB |
显示代码纯文本
- #include <iostream>
- #include <fstream>
-
- using namespace std;
-
- ifstream fin("mod.in");
- ofstream fout("mod.out");
- int a, b, c = 1, x, y, gbd, gcd(int, int);
- #define cin fin
- #define cout fout
-
- main()
- {
- cin >> a >> b;
-
- gbd = a / gcd(a, b) * b;
- x = (x + b) % b;
-
- cout << x;
- }
-
- int gcd(int a, int b)
- {
- if (b == 0){
- y = 0;
- x = c / a;
- return a;
- }
- int g = gcd(b, a % b), xx, yy;
- xx = y;
- yy = x - y * (a / b);
- x = xx;
- y = yy;
- return g;
- }