buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
#include <bits/stdc++.h> using namespace std; #define REP(i, s, n) for (int i = s; i < n; ++i) #define rep(i, n) REP(i, 0, n) #define SORT(c) sort((c).begin(), (c).end()) #define IINF INT_MAX #define LLINF LLONG_MAX #define DEBUG false int main() { long long int a, b, r = 1; cin >> a >> b; if (a < b) { long...
#include <bits/stdc++.h> using namespace std; #define REP(i, s, n) for (int i = s; i < n; ++i) #define rep(i, n) REP(i, 0, n) #define SORT(c) sort((c).begin(), (c).end()) #define IINF INT_MAX #define LLINF LLONG_MAX #define DEBUG false int main() { long long int a, b, r = 1; while (cin >> a >> b) { if (a < b)...
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
153
6
#include <iostream> int gcd(int a, int b) { if (b == 0) { return a; } return gcd(b, a % b); } int main(void) { int a; int b; int g; while (std::cin >> a >> b) { g = gcd(a, b); std::cout << g << std::endl; std::cout << (int)((double)a / (double)g * (double)b) << std::endl; } return 0;...
#include <iostream> int gcd(int a, int b) { if (b == 0) { return a; } return gcd(b, a % b); } int main(void) { int a; int b; int g; while (std::cin >> a >> b) { g = gcd(a, b); std::cout << g << " "; std::cout << (int)((double)a / (double)g * (double)b) << std::endl; } return 0; }
[["-", 8, 9, 0, 1, 0, 16, 12, 343, 345, 348], ["-", 8, 9, 0, 1, 0, 16, 12, 343, 0, 349], ["-", 8, 9, 0, 1, 0, 16, 12, 343, 141, 22], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 62], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
112
6
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long int lld; const lld mod = 1e9 + 7; const lld INF = 1e9; // const lld MAXN = 1e9; lld gcd(lld x, lld y) { if (y ==...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long int lld; const lld mod = 1e9 + 7; const lld INF = 1e9; // const lld MAXN = 1e9; lld gcd(lld x, lld y) { if (y ==...
[["-", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 31, 22], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]]
1
147
6
#include <iostream> using namespace std; int main() { int a, b, lcm = 0, r, x, y, count = 0; while (cin >> a >> b) { count++; if (count == 50) break; x = a; y = b; while (1) { r = a % b; a = b; b = r; if (r == 0) break; } lcm = a; cout << lcm << ...
#include <iostream> using namespace std; int main() { long int a, b, lcm = 0, r, x, y, count = 0; while (cin >> a >> b) { count++; if (count == 50) break; x = a; y = b; while (1) { r = a % b; a = b; b = r; if (r == 0) break; } lcm = a; cout << lc...
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
108
1
#include <algorithm> #include <iostream> using namespace std; int main() { int a, b; while (cin >> a >> b) { cout << __gcd(a, b) << " " << (a * b) / __gcd(a, b) << endl; } return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { long long int a, b; while (cin >> a >> b) { cout << __gcd(a, b) << " " << (a * b) / __gcd(a, b) << endl; } return 0; }
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
60
2
#include <algorithm> #include <cstdlib> #include <iostream> #include <math.h> using namespace std; const int MAX_N = 10000; unsigned long long int a, b; unsigned long long gcd(unsigned long long a, unsigned long long b) { if (b) return gcd(b, a % b); else return a; } unsigned long long lcm(unsigned long ...
#include <algorithm> #include <cstdlib> #include <iostream> #include <math.h> using namespace std; const int MAX_N = 10000; unsigned long long int a, b; unsigned long long gcd(unsigned long long a, unsigned long long b) { if (b) return gcd(b, a % b); else return a; } unsigned long long lcm(unsigned long ...
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
129
6
#include <cstdio> #include <iostream> using namespace std; int main() { int a, b, c, a1, b1, p, min, max; while (cin >> a >> b) { if (a < b) { p = a; a = b; b = p; } a1 = a; b1 = b; while (a % b != 0) { c = a % b; a = b; b = c; } min = b; max = a1 ...
#include <cstdio> #include <iostream> using namespace std; int main() { long long a, b, c, a1, b1, p, min, max; while (cin >> a >> b) { if (a < b) { p = a; a = b; b = p; } a1 = a; b1 = b; while (a % b != 0) { c = a % b; a = b; b = c; } min = b; max...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
120
5
#include <iostream> using namespace std; int gcd(int x, int y) { //?????????????????????????????? int r; if (x < y) swap(x, y); while (y > 0) { r = x % y; x = y; y = r; } return x; } int main() { int a, b, c; while (cin >> a >> b) { c = gcd(a, b); cout << c << " " << a * b / c <...
#include <iostream> using namespace std; int gcd(int x, int y) { //?????????????????????????????? int r; if (x < y) swap(x, y); while (y > 0) { r = x % y; x = y; y = r; } return x; } int main() { unsigned long long a, b, c; while (cin >> a >> b) { c = gcd(a, b); cout << c << " "...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 87], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
110
4
#include <cstdio> #include <iostream> using namespace std; int GCD(int x, int y) { if (x < y) { swap(x, y); } if (y == 0) { return x; } return GCD(y, x % y); } int LCM(int x, int y) { return x * y / GCD(x, y); } int main() { int a, b; while (cin >> a >> b) { printf("%d %d\n", GCD(a, b), LCM(a...
#include <cstdio> #include <iostream> using namespace std; int GCD(int x, int y) { if (x < y) { swap(x, y); } if (y == 0) { return x; } return GCD(y, x % y); } int LCM(int x, int y) { return x / GCD(x, y) * y; } int main() { int a, b; while (cin >> a >> b) { printf("%d %d\n", GCD(a, b), LCM(a...
[["-", 8, 9, 0, 37, 0, 16, 31, 16, 17, 48], ["-", 8, 9, 0, 37, 0, 16, 31, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 48], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 12, 22]]
1
124
4
#include <iostream> using namespace std; int GCD(int a, int b) { if (a % b == 0) { return b; } if (b % a == 0) { return a; } if (a > b) { return GCD(a % b, b); } if (a < b) { return GCD(a, b % a); } } int main() { int a, b; while (cin >> a >> b) { int n = GCD(a, b); co...
#include <iostream> using namespace std; int GCD(int a, int b) { if (a % b == 0) { return b; } if (b % a == 0) { return a; } if (a > b) { return GCD(a % b, b); } if (a < b) { return GCD(a, b % a); } } int main() { int a, b; while (cin >> a >> b) { int n = GCD(a, b); co...
[["-", 0, 16, 31, 16, 12, 16, 31, 16, 17, 48], ["-", 0, 16, 31, 16, 12, 16, 31, 16, 12, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
129
4
#include <iostream> using namespace std; int gcd(int a, int b) { if (a < b) { int tmp = a; a = b; b = tmp; } if (a % b == 0) return b; return gcd(b, a % b); } int main() { int a = 0; int b = 0; while (cin >> a >> b) { int n = gcd(a, b); cout << n << " " << (a * b) / n << endl; }...
#include <iostream> using namespace std; int gcd(int a, int b) { if (a < b) { int tmp = a; a = b; b = tmp; } if (a % b == 0) return b; return gcd(b, a % b); } int main() { int a = 0; int b = 0; while (cin >> a >> b) { int n = gcd(a, b); cout << n << " " << a / n * b << endl; } ...
[["-", 0, 16, 31, 16, 12, 16, 31, 23, 0, 24], ["-", 31, 16, 12, 16, 31, 23, 0, 16, 17, 48], ["-", 31, 16, 12, 16, 31, 23, 0, 16, 12, 22], ["-", 0, 16, 31, 16, 12, 16, 31, 23, 0, 25], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
116
6
#include <iostream> using namespace std; int main(void) { int a, b, fl; while (cin >> a >> b) { fl = 0; for (int i = 1; fl == 0; i++) { if (a % i == 0 && b % (a / i) == 0) { cout << a / i << " "; fl++; } else ; } fl = 0; for (int i = 1; fl == 0; i++) { i...
#include <iostream> using namespace std; int main(void) { int a, b, fl; while (cin >> a >> b) { fl = 0; for (int i = 1; fl == 0; i++) { if (a % i == 0 && b % (a / i) == 0) { cout << a / i << " "; fl++; } else ; } fl = 0; for (int i = 1; fl == 0; i++) { i...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22]]
1
135
4
#include <iostream> #include <vector> using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { while (true) { int a, b; cin >> a >> b; if (cin.eof()) return 0; int g = gcd(a, b); cout << g << ' ' << a / g * b; } }
#include <iostream> #include <vector> using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { while (true) { int a, b; cin >> a >> b; if (cin.eof()) return 0; int g = gcd(a, b); cout << g << ' ' << a / g * b << endl; } }
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
1
96
2
#include <iostream> using namespace std; long gcd(long a, long b) { if (b == 0) return a; else return gcd(b, a % b); } int main(void) { int a, b; while (cin >> a >> b) { long s = gcd(a, b); cout << s << " " << a * b / s << endl; } return 0; }
#include <iostream> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; else return gcd(b, a % b); } int main(void) { long long a, b; while (cin >> a >> b) { long long s = gcd(a, b); cout << s << " " << a * b / s << endl; } return 0; }
[["+", 36, 36, 0, 30, 0, 14, 39, 86, 0, 96], ["+", 49, 53, 54, 55, 0, 56, 39, 86, 0, 96], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 0, 52, 8, 9, 0, 43, 39, 86, 0, 96]]
1
88
7
#include <iostream> #include <stdio.h> using namespace std; int gcd(int a, int b) { int temp; if (a < b) { temp = a; a = b; b = temp; } if (b < 1) return -1; if (a % b == 0) return b; return gcd(b, a % b); } int main() { int a, b; while (1) { cin >> a >> b; if (cin.eof()...
#include <iostream> #include <stdio.h> using namespace std; int gcd(int a, int b) { int temp; if (a < b) { temp = a; a = b; b = temp; } if (b < 1) return -1; if (a % b == 0) return b; return gcd(b, a % b); } int main() { int a, b; while (1) { cin >> a >> b; if (cin.eof()...
[["+", 0, 16, 31, 16, 31, 16, 12, 103, 0, 104], ["+", 0, 16, 31, 16, 31, 16, 12, 103, 0, 125], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
131
4
#include <cstdio> #include <iostream> using namespace std; int gcd(int a, int b) { int r; while ((r = a % b) != 0) { a = b; b = r; } return b; } int main(void) { int a, b, tmp; if (a < b) { tmp = b; b = a; a = tmp; } while (cin >> a >> b) { int lcm = b * a / gcd(a, b); cout...
#include <cstdio> #include <iostream> using namespace std; int gcd(int a, int b) { int r; while ((r = a % b) != 0) { a = b; b = r; } return b; } int main(void) { int a, b, tmp; if (a < b) { tmp = b; b = a; a = tmp; } while (cin >> a >> b) { int lcm = b / gcd(a, b) * a; cout...
[["-", 0, 43, 49, 50, 51, 16, 31, 16, 17, 48], ["-", 0, 43, 49, 50, 51, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 48], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22]]
1
125
4
#include <cstdio> #include <iostream> using namespace std; int gcd(int a, int b) { int r; while ((r = a % b) != 0) { a = b; b = r; } return b; } int main(void) { int a, b; while (cin >> a >> b) { int lcm = (a * b) / gcd(a, b); cout << gcd(a, b) << " " << lcm << endl; } return 0; }
#include <cstdio> #include <iostream> using namespace std; int gcd(int a, int b) { int r; while ((r = a % b) != 0) { a = b; b = r; } return b; } int main(void) { int a, b; while (cin >> a >> b) { int lcm = b / gcd(a, b) * a; cout << gcd(a, b) << " " << lcm << endl; } return 0; }
[["-", 0, 43, 49, 50, 51, 16, 31, 23, 0, 24], ["-", 49, 50, 51, 16, 31, 23, 0, 16, 31, 22], ["-", 49, 50, 51, 16, 31, 23, 0, 16, 17, 48], ["-", 0, 43, 49, 50, 51, 16, 31, 23, 0, 25], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 48], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22]]
1
105
6
#include <iostream> using namespace std; int gcd(int a, int b) { if (b = 0) { return a; } return gcd(b, a % b); } int main() { while (true) { int a, b; cin >> a >> b; if (cin.eof()) break; int g = gcd(a, b); cout << g << " " << a / g * b << endl; } return 0; }
#include <iostream> using namespace std; int gcd(int a, int b) { if (b == 0) { return a; } return gcd(b, a % b); } int main() { while (true) { int a, b; cin >> a >> b; if (cin.eof()) break; int g = gcd(a, b); cout << g << " " << a / g * b << endl; } return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60]]
1
100
2
#include <algorithm> #include <cmath> #include <iostream> #include <stdio.h> #include <string> using namespace std; int gcd(int x, int y) { if (x < y) swap(x, y); int r = 1; while (r) { r = x % y; x = y; y = r; } return x; } int main() { int a, b; while (cin >> a >> b) { cout << gcd(a,...
#include <algorithm> #include <cmath> #include <iostream> #include <stdio.h> #include <string> using namespace std; int gcd(int x, int y) { if (x < y) swap(x, y); int r = 1; while (r) { r = x % y; x = y; y = r; } return x; } int main() { int a, b; while (cin >> a >> b) { cout << gcd(a,...
[["+", 31, 16, 12, 16, 31, 16, 31, 74, 0, 24], ["+", 31, 16, 31, 74, 39, 77, 39, 86, 0, 96], ["+", 31, 16, 12, 16, 31, 16, 31, 74, 0, 25]]
1
113
4
#include <iostream> using namespace std; int gcd(int a, int b) { if ((0 == a) || (0 == b)) return 0; while (a != b) { if (a > b) a = a - b; else b = b - a; } return a; } int main(void) { int a, b; while (cin >> a >> b) { int lcm = a * b / gcd(a, b); cout << gcd(a, b) <<...
#include <iostream> using namespace std; int gcd(int a, int b) { if ((0 == a) || (0 == b)) return 0; while (a != b) { if (a > b) a = a - b; else b = b - a; } return a; } int main(void) { long a, b; while (cin >> a >> b) { int lcm = a * b / gcd(a, b); cout << gcd(a, b) <...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
117
2
#define _USE_MATH_DEFINES #include <algorithm> #include <iostream> #include <math.h> #include <numeric> #include <vector> using namespace std; int main() { #define int long long int a, b, r, x, temp; cin >> a >> b; x = a * b; if (a < b) { temp = a; a = b; b = temp; } r = a % b; while (r != 0) ...
#define _USE_MATH_DEFINES #include <algorithm> #include <iostream> #include <math.h> #include <numeric> #include <vector> using namespace std; int main() { #define int long long int a, b, r, x, temp; while (cin >> a >> b) { x = a * b; if (a < b) { temp = a; a = b; b = temp; } r = a...
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
113
6
#include <iostream> using namespace std; int gcd(int a, int b) { return (b > 0) ? gcd(b, a % b) : a; } int lcm(int a, int b) { return a / gcd(a, b) * b; } int main() { int a, b, n, m; while (cin >> a >> b) { cout << gcd(a, b) << " " << lcm(a, b); } }
#include <iostream> using namespace std; int gcd(int a, int b) { return (b > 0) ? gcd(b, a % b) : a; } int lcm(int a, int b) { return a / gcd(a, b) * b; } int main() { int a, b, n, m; while (cin >> a >> b) { cout << gcd(a, b) << " " << lcm(a, b) << endl; } }
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
1
103
2
#include <iostream> int e(int a, int b) { if (a < b) a ^= b ^= a ^= b; while (a %= b) a ^= b ^= a ^= b; return b; } int main() { for (int a, b, c, s; s = !(std::cin >> a >> b).eof(); s && printf("%d %d\n", c, a * b / c)) c = e(a, b); }
#include <iostream> int e(int a, int b) { if (a < b) a ^= b ^= a ^= b; while (a %= b) a ^= b ^= a ^= b; return b; } int main() { for (int a, b, c, s; s = !(std::cin >> a >> b).eof(); s && printf("%ld %ld\n", c, a / c * b)) c = e(a, b); }
[["-", 26, 16, 12, 2, 3, 4, 0, 5, 0, 6], ["+", 26, 16, 12, 2, 3, 4, 0, 5, 0, 6], ["-", 12, 2, 3, 4, 0, 16, 31, 16, 17, 48], ["-", 12, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["+", 26, 16, 12, 2, 3, 4, 0, 16, 17, 48], ["+", 26, 16, 12, 2, 3, 4, 0, 16, 12, 22]]
1
105
6
#include <iostream> int e(int a, int b) { while (a %= b) a ^= b ^= a ^= b; return b; } int main() { for (int a, b, c, s; s = !(std::cin >> a >> b).eof(); s && printf("%d %d\n", c, a * b / c)) c = e(a, b); }
#include <iostream> int e(int a, int b) { while (a %= b) a ^= b ^= a ^= b; return b; } int main() { for (int a, b, c, s; s = !(std::cin >> a >> b).eof(); s && printf("%ld %ld\n", c, a / c * b)) c = e(a, b); }
[["-", 26, 16, 12, 2, 3, 4, 0, 5, 0, 6], ["+", 26, 16, 12, 2, 3, 4, 0, 5, 0, 6], ["-", 12, 2, 3, 4, 0, 16, 31, 16, 17, 48], ["-", 12, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["+", 26, 16, 12, 2, 3, 4, 0, 16, 17, 48], ["+", 26, 16, 12, 2, 3, 4, 0, 16, 12, 22]]
1
91
6
#include <iostream> using namespace std; int gcm(int a, int b) { if (b == 0) return a; return gcm(b, a % b); } int main() { int x, y; while (cin >> x >> y) { int a = gcm(x, y); cout << a << " " << x * y / a << endl; } }
#include <iostream> using namespace std; int gcm(int a, int b) { if (b == 0) return a; return gcm(b, a % b); } int main() { int x, y; while (cin >> x >> y) { int a = gcm(x, y); cout << a << " " << x / a * y << endl; } }
[["-", 0, 16, 31, 16, 12, 16, 31, 16, 17, 48], ["-", 0, 16, 31, 16, 12, 16, 31, 16, 12, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
83
4
#include <iostream> using namespace std; int main() { int a, b; int temp; int big, small; while (cin >> a >> b) { if (a < b) { big = b; small = a; } else { big = a; small = b; } for (;;) { temp = big % small; if (temp == 0) { break; } ...
#include <iostream> using namespace std; int main() { int a, b; int temp; int big, small; while (cin >> a >> b) { if (a < b) { big = b; small = a; } else { big = a; small = b; } for (;;) { temp = big % small; if (temp == 0) { break; } ...
[["-", 0, 16, 31, 16, 12, 16, 31, 16, 17, 48], ["-", 0, 16, 31, 16, 12, 16, 31, 16, 12, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
124
4
#include <iostream> #include <math.h> using namespace std; int calc_gcj(int a, int b) { int A = 0, B = 0; if (a == max(a, b)) { A = a; B = b; } else { A = b; B = a; } if (A == B) return A; else return calc_gcj(B, A - B); return -1; } void solve(int a, int b) { int gcj = calc_g...
#include <iostream> #include <math.h> using namespace std; int calc_gcj(int a, int b) { int A = 0, B = 0; if (a == max(a, b)) { A = a; B = b; } else { A = b; B = a; } if (A == B) return A; else return calc_gcj(B, A - B); return -1; } void solve(int a, int b) { int gcj = calc_g...
[["-", 0, 43, 49, 50, 51, 16, 31, 16, 17, 48], ["-", 0, 43, 49, 50, 51, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 48], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22]]
1
156
4
#include <cstdio> int m, n; int GCD(int m, int n) { while (1) { m = m % n; if (m == 0) return n; n = n % m; if (n == 0) return m; } } int LCM(int m, int n) { return ((m / GCD(m, n)) * n); // lcm = m * n / gcd(m,n) } int main() { while (scanf("%d%d", &m, &n) != EOF) { printf("%...
#include <cstdio> int m, n; int GCD(int m, int n) { while (1) { m = m % n; if (m == 0) return n; n = n % m; if (n == 0) return m; } } int LCM(int m, int n) { return ((m / GCD(m, n)) * n); // lcm = m * n / gcd(m,n) } int main() { while (scanf("%d%d", &m, &n) != EOF) { printf("%...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
131
1
#include <stdio.h> int main() { long long int a, b, x, y; scanf("%lld%lld", &a, &b); x = a; y = b; while (a != b) { if (a > b) { a -= b; } else { b -= a; } } printf("%lld %lld\n", a, x / a * y); return 0; }
#include <stdio.h> int main() { long long int a, b, x, y; while (~scanf("%lld%lld", &a, &b)) { x = a; y = b; while (a != b) { if (a > b) { a -= b; } else { b -= a; } } printf("%lld %lld\n", a, x / a * y); } return 0; }
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["+", 8, 9, 0, 52, 15, 339, 51, 91, 17, 92], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
86
7
#include <algorithm> #include <iostream> using namespace std; int gcd(int, int); int lcm(int, int); int tes(int, int); int main() { int a, b; while (cin >> a >> b) { cout << gcd(a, b); cout << " " << lcm(a, b) << endl; } } int gcd(int a, int b) { int n; while (a != b) { if (a > b) a = a - ...
#include <algorithm> #include <iostream> using namespace std; int gcd(int, int); int lcm(int, int); int tes(int, int); int main() { int a, b; while (cin >> a >> b) { cout << gcd(a, b); cout << " " << lcm(a, b) << endl; } } int gcd(int a, int b) { int n; while (a != b) { if (a > b) a = a - ...
[["-", 0, 37, 0, 16, 31, 23, 0, 16, 17, 48], ["-", 0, 37, 0, 16, 31, 23, 0, 16, 12, 22], ["-", 8, 9, 0, 37, 0, 16, 31, 23, 0, 25], ["+", 31, 23, 0, 16, 12, 2, 3, 4, 0, 25], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 48], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 12, 22]]
1
149
6
#include <iostream> using namespace std; int main() { int a, b, r, x, y; while (cin >> a >> b) { if (a >= b) { x = a; y = r = b; } else { x = b; y = r = a; } while (1) { r = x % y; if (!r) break; x = y; y = r; } x = (a * b) / y; ...
#include <iostream> using namespace std; int main() { int a, b, r, x, y; while (cin >> a >> b) { if (a >= b) { x = a; y = r = b; } else { x = b; y = r = a; } while (1) { r = x % y; if (!r) break; x = y; y = r; } x = (a / y) * b; ...
[["-", 0, 11, 12, 16, 31, 23, 0, 16, 17, 48], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22], ["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
116
6
#include <iostream> using namespace std; int gl(int a, int b, int x, int y); int main() { int a, b; while (cin >> a >> b) { gl(a, b, a, b); } return 0; } int gl(int a, int b, int x, int y) { if (b == 0) { cout << a << " " << x * y / a << endl; return 0; } return gl(b, a % b, x, y); }
#include <iostream> using namespace std; int gl(int a, int b, int x, int y); int main() { int a, b; while (cin >> a >> b) { gl(a, b, a, b); } return 0; } int gl(int a, int b, int x, int y) { if (b == 0) { cout << a << " " << x / a * y << endl; return 0; } return gl(b, a % b, x, y); }
[["-", 0, 16, 31, 16, 12, 16, 31, 16, 17, 48], ["-", 0, 16, 31, 16, 12, 16, 31, 16, 12, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
115
4
#include <iostream> using namespace std; int SKB(double x, double y, double w) { double n = (x * y) / w; return (int)n; } int YUK(int x, int y) { int c; c = x % y; if (c == 0) { return y; } else { return YUK(y, c); } } int main() { int a, b; while (cin >> a >> b) { int d; if (a >= ...
#include <iostream> using namespace std; int SKB(double x, double y, double w) { double n = (x * y) / w; return (int)n; } int YUK(int x, int y) { int c; c = x % y; if (c == 0) { return y; } else { return YUK(y, c); } } int main() { int a, b; while (cin >> a >> b) { int d; if (a >= ...
[["-", 0, 1, 0, 16, 31, 16, 12, 103, 0, 44], ["+", 0, 1, 0, 16, 31, 16, 12, 103, 0, 125]]
1
175
4
/* 2012-07-08T09:04:13 */ #define DEBUG_ON #define CONDITION true using namespace std; /*{{{*/ #include <algorithm> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <iterator...
/* 2012-07-08T09:04:13 */ #define DEBUG_ON #define CONDITION true using namespace std; /*{{{*/ #include <algorithm> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <iterator...
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
695
6
//#include<cstdio> #include <iostream> using namespace std; int main() { long a, b, t, gcd, lcm; while (cin >> a >> b) { t = a * b; while (a != b) { while (a > b) a -= b; while (a < b) b -= a; } gcd = a; lcm = t / gcd; cout << gcd << lcm << endl; } return 0; ...
//#include<cstdio> #include <iostream> using namespace std; int main() { long long a, b, t, gcd, lcm; while (cin >> a >> b) { t = a * b; while (a != b) { while (a > b) a -= b; while (a < b) b -= a; } gcd = a; lcm = t / gcd; cout << gcd << " " << lcm << endl; } ...
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 0, 1, 0, 16, 31, 16, 31, 16, 17, 151], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]]
1
89
5
#include <iostream> using namespace std; int Func_gcd(int num1, int num2) { int surplus; while ((surplus = num1 % num2) != 0) { num1 = num2; num2 = surplus; } return num2; } int main() { int gcd, lcm; int num1, num2; while (cin >> num1 >> num2) { gcd = Func_gcd(num1, num2); lcm = (num...
#include <iostream> using namespace std; int Func_gcd(int num1, int num2) { int surplus; while ((surplus = num1 % num2) != 0) { num1 = num2; num2 = surplus; } return num2; } int main() { int gcd, lcm; int num1, num2; while (cin >> num1 >> num2) { gcd = Func_gcd(num1, num2); lcm = num1...
[["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 17, 48], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22], ["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
107
6
#include <iostream> using namespace std; int gcm_sub(int c, int d) { if (c % d == 0) return d; else return gcm_sub(d, c % d); } int gcm(int a, int b) { if (a >= b) return gcm_sub(a, b); else if (b > a) return gcm_sub(b, a); } int lcm(int a, int b) { return (a * b) / gcm(a, b); } int main() { ...
#include <iostream> using namespace std; int gcm_sub(int c, int d) { if (c % d == 0) return d; else return gcm_sub(d, c % d); } int gcm(int a, int b) { if (a >= b) return gcm_sub(a, b); else if (b > a) return gcm_sub(b, a); } int lcm(int a, int b) { return a / gcm(a, b) * b; } int main() { ...
[["-", 8, 9, 0, 37, 0, 16, 31, 23, 0, 24], ["-", 0, 37, 0, 16, 31, 23, 0, 16, 17, 48], ["-", 0, 37, 0, 16, 31, 23, 0, 16, 12, 22], ["-", 8, 9, 0, 37, 0, 16, 31, 23, 0, 25], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 48], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 12, 22]]
1
162
6
#include <iostream> using namespace std; int main() { int a, b, c, d, tmp = 0; while (cin >> a >> b) { if (a < b) { swap(a, b); } c = a; d = b; while (b) { tmp = b; b = a % b; a = tmp; } cout << a << " " << c * d / a << endl; } }
#include <iostream> using namespace std; int main() { long long int a, b, c, d, tmp = 0; while (cin >> a >> b) { if (a < b) { swap(a, b); } c = a; d = b; while (b) { tmp = b; b = a % b; a = tmp; } cout << a << " " << c * d / a << endl; } }
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
94
2
#include <iostream> using namespace std; int GCD(int a, int b); int LCM(int a, int b); int main() { int a, b, gcd, lcm; while (cin >> a >> b) { if (a == 0 || b == 0) cout << "0 0" << endl; gcd = GCD(a, b); lcm = LCM(a, b); cout << gcd << ' ' << lcm << endl; } } int GCD(int a, int b) { ...
#include <iostream> using namespace std; int GCD(int a, int b); int LCM(int a, int b); int main() { int a, b, gcd, lcm; while (cin >> a >> b) { if (a == 0 || b == 0) cout << "0 0" << endl; gcd = GCD(a, b); lcm = LCM(a, b); cout << gcd << ' ' << lcm << endl; } } int GCD(int a, int b) { ...
[["-", 0, 23, 0, 16, 31, 23, 0, 16, 17, 48], ["-", 0, 23, 0, 16, 31, 23, 0, 16, 12, 22], ["-", 0, 37, 0, 23, 0, 16, 31, 23, 0, 25], ["+", 31, 23, 0, 16, 12, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 37, 0, 23, 0, 16, 17, 48], ["+", 8, 9, 0, 37, 0, 23, 0, 16, 12, 22]]
1
167
6
#include <iostream> using namespace std; int main() { int a, b, tmp, m = 0, s = 0, ai, bi; while (cin >> a >> b) { ai = a; bi = b; while (1) { if (a < b) { tmp = a; a = b; b = tmp; } if (a % b == 0) { m = b; break; } else a = a % b...
#include <iostream> using namespace std; int main() { unsigned long long int a, b, tmp, m = 0, s = 0, ai, bi; while (cin >> a >> b) { ai = a; bi = b; while (1) { if (a < b) { tmp = a; a = b; b = tmp; } if (a % b == 0) { m = b; break; } els...
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 87], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
121
3
#include <cstdlib> #include <iostream> using namespace std; int main() { int a, b, ba, bb; int gcd, lcd = 0; while (cin >> a >> b) { ba = a; bb = b; while (b != 0) { gcd = b; b = a % b; a = gcd; } lcd = ba * bb / gcd; cout << gcd << " " << lcd << endl; } return EXIT...
#include <cstdlib> #include <iostream> using namespace std; int main() { long long a, b, ba, bb; long long gcd, lcd = 0; while (cin >> a >> b) { ba = a; bb = b; while (b != 0) { gcd = b; b = a % b; a = gcd; } lcd = ba * bb / gcd; cout << gcd << " " << lcd << endl; } ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
93
6
#include <stdio.h> int main(void) { int x[1000], x2[1000], y[1000], y2[1000], z[1000], i = 0, j = 0, gcd[1000] = {0}, lcm[1000] = {0}; while (i != -1) { scanf("%d %d", &x[i], &y[i]); x2[i] = x[i]; y2[i] = y[i]; if (x[i] <= 0 || x[i] > 2000000000 || y[i] <= 0 || y[i] > 2000000000) break...
#include <stdio.h> int main(void) { long int x[1000], x2[1000], y[1000], y2[1000], z[1000], i = 0, j = 0, gcd[1000] = {0}, lcm[1000] = {0}; while (i != -1) { scanf("%d %d", &x[i], &y[i]); x2[i] = x[i]; y2[i] = y[i]; if (x[i] <= 0 || x[i] > 2000000000 || y[i] <= 0 || y[i] > 2000000000) ...
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
1
263
3
#include <iostream> using namespace std; int main() { int a, b, e, f, l; while (cin >> a >> b) { e = a; f = b; while (1) { if (e > f) { e = e - f; } if (f > e) { f = f - e; } if (f == e) { l = e; cout << l << " " << (a * b) / l << endl; ...
#include <iostream> using namespace std; int main() { unsigned long long a, b, e, f, l; while (cin >> a >> b) { e = a; f = b; while (1) { if (e > f) { e = e - f; } if (f > e) { f = f - e; } if (f == e) { l = e; cout << l << " " << (a * b) / ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 87], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
111
4
#include <iostream> using namespace std; long int Gcm(long int a, long int b) { long int temp = 0; long int r = 1; // aとbの最大公約数を求める // a,b入力を行う(a>b)。a=b*q+rの形で計算していく // b%rの値が0になったときのbがa,bの最大公約数(cとする)となる //最小公倍数は、c*a'=a,c*b'=bを満たすa',b'とcとの積である if (a < b) { temp = a; a = b; b = temp; } wh...
#include <iostream> using namespace std; long int Gcm(long int a, long int b) { long int temp = 0; long int r = 1; // aとbの最大公約数を求める // a,b入力を行う(a>b)。a=b*q+rの形で計算していく // b%rの値が0になったときのbがa,bの最大公約数(cとする)となる //最小公倍数は、c*a'=a,c*b'=bを満たすa',b'とcとの積である if (a < b) { temp = a; a = b; b = temp; } wh...
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
150
6
#include <iostream> int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int lcm(int a, int b) { return a / gcd(a, b) * b; } int main() { int x, y; std::cin >> x >> y; std::cout << gcd(x, y) << ' ' << lcm(x, y) << std::endl; return 0; }
#include <iostream> int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int lcm(int a, int b) { return a / gcd(a, b) * b; } int main() { int x, y; while (std::cin >> x >> y) std::cout << gcd(x, y) << ' ' << lcm(x, y) << std::endl; return 0; }
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25]]
1
103
4
#include <cstdio> #include <iostream> using namespace std; int main() { int a, b, gcd, lcm, x, y, r; while (cin >> a >> b) { r = 1; x = a; y = b; while (r = x % y) { x = y; y = r; } gcd = y; lcm = a * b / gcd; cout << gcd << " " << lcm << endl; } return 0; }
#include <cstdio> #include <iostream> using namespace std; int main() { long long unsigned int a, b, gcd, lcm, x, y, r; while (cin >> a >> b) { r = 1; x = a; y = b; while (r = x % y) { x = y; y = r; } gcd = y; lcm = a * b / gcd; cout << gcd << " " << lcm << endl; } ...
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 87]]
1
96
3
#include <iostream> using namespace std; int GCD(int x, int y) { if (x < y) { swap(x, y); } if (x % y == 0) { return y; } else { GCD(y, x %= y); } } int main() { unsigned int a, b; while (cin >> a >> b) { cout << GCD(a, b) << " " << a / GCD(a, b) * b; } return 0; }
#include <iostream> using namespace std; int GCD(int x, int y) { if (x < y) { swap(x, y); } if (x % y == 0) { return y; } else { GCD(y, x %= y); } } int main() { unsigned int a, b; while (cin >> a >> b) { cout << GCD(a, b) << " " << a / GCD(a, b) * b << endl; } return 0; }
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
1
106
2
#include <cmath> #include <iostream> using namespace std; int main() { // your code goes here long long int a, b; long long int miner, maxer; while (cin >> a >> b) { int a2 = a, b2 = b; while (max(a2, b2) % min(a2, b2) != 0) { if (a2 > b2) a2 = a2 - b2; else b2 = b2 - a2; ...
#include <cmath> #include <iostream> using namespace std; int main() { // your code goes here long long int a, b; long long int miner, maxer; while (cin >> a >> b) { int a2 = a, b2 = b; while (max(a2, b2) % min(a2, b2) != 0) { if (a2 > b2) a2 = a2 - b2; else b2 = b2 - a2; ...
[["-", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 62], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
115
4
#include <stdio.h> int main() { int buf1[50], buf2[50]; int k = 0; while (scanf("%d %d", &buf1[k], &buf2[k]) != EOF) k++; for (int i = 0; i < k; i++) { int b1 = buf1[i], b2 = buf2[i]; int m, n; if (b1 < b2) { m = b2, n = b1; } else if (b1 > b2) { m = b1, n = b2; } else ...
#include <stdio.h> int main() { int buf1[50], buf2[50]; int k = 0; while (scanf("%d %d", &buf1[k], &buf2[k]) != EOF) k++; for (int i = 0; i < k; i++) { int b1 = buf1[i], b2 = buf2[i]; int m, n; if (b1 < b2) { m = b2, n = b1; } else if (b1 > b2) { m = b1, n = b2; } else { ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
205
3
#include <iostream> using namespace std; int gcd(int m, int n) { if ((m == 0) || (n == 0)) return 0; while (m != n) { if (m > n) m = m - n; else n = n - m; } return m; } int lcm(int m, int n) { if ((m == 0) || (n == 0)) return 0; return ((m / gcd(m, n)) * n); } int main() { ...
#include <iostream> using namespace std; int gcd(int m, int n) { if ((m == 0) || (n == 0)) return 0; while (m != n) { if (m > n) m = m - n; else n = n - m; } return m; } int lcm(int m, int n) { if ((m == 0) || (n == 0)) return 0; return ((m / gcd(m, n)) * n); } int main() { ...
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
156
6
#include <iostream> using namespace std; //最大公約数 int gcd(int a, int b) { int r; while ((r = a % b) != 0) { a = b; b = r; } return b; } //最小公倍数 int lcm(int a, int b) { return (a * b / gcd(a, b)); } int main() { int a, b; while (cin >> a >> b) { if (a == -1 or b == -1) break; while ...
#include <iostream> using namespace std; //最大公約数 int gcd(int a, int b) { int r; while ((r = a % b) != 0) { a = b; b = r; } return b; } //最小公倍数 int lcm(int a, int b) { return ((a / gcd(a, b)) * b); } int main() { int a, b; while (cin >> a >> b) { if (a == -1 or b == -1) break; whil...
[["+", 0, 37, 0, 23, 0, 16, 31, 23, 0, 24], ["-", 0, 37, 0, 23, 0, 16, 31, 16, 17, 48], ["-", 0, 37, 0, 23, 0, 16, 31, 16, 12, 22], ["+", 31, 23, 0, 16, 12, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 37, 0, 23, 0, 16, 17, 48], ["+", 8, 9, 0, 37, 0, 23, 0, 16, 12, 22]]
1
170
6
#include <algorithm> #include <iostream> int getGCD(int a, int b) { if (b == 0) return a; return getGCD(b, a % b); } int main() { int a, b, GCD; while (std::cin >> a >> b) { if (a < b) std::swap(a, b); GCD = getGCD(a, b); std::cout << GCD << " " << (a * b) / GCD << std::endl; } }
#include <algorithm> #include <iostream> int getGCD(int a, int b) { if (b == 0) return a; return getGCD(b, a % b); } int main() { int a, b, GCD; while (std::cin >> a >> b) { if (a < b) std::swap(a, b); GCD = getGCD(a, b); std::cout << GCD << " " << (a / GCD) * b << std::endl; } }
[["-", 31, 16, 12, 16, 31, 23, 0, 16, 17, 48], ["-", 31, 16, 12, 16, 31, 23, 0, 16, 12, 22], ["-", 0, 16, 31, 16, 12, 16, 31, 23, 0, 25], ["+", 0, 16, 31, 16, 12, 16, 31, 23, 0, 25], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
105
6
#include <iostream> #include <list> #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) > (b) ? (b) : (a)) using namespace std; int main() { long a, b, r, x, y; list<long> aby; while (!(cin >> a >> b).eof()) { x = a, y = b; while (1) { r = MAX(x, y) % MIN(x, y); if (r == 0) ...
#include <iostream> #include <list> #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) > (b) ? (b) : (a)) using namespace std; int main() { long a, b, r, x, y; list<long> aby; while (!(cin >> a >> b).eof()) { x = a, y = b; while (1) { r = MAX(x, y) % MIN(x, y); if (r == 0) ...
[["-", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22]]
1
212
4
#include <iostream> using namespace std; int main() { long a, b, t, m, n, l; while (cin >> a >> b) { if (a >= b) { m = a; n = b; } else { n = a; m = b; } while (n != 0) { t = n; n = m % n; m = t; } l = a * b / m; cout << m << l << endl; } ret...
#include <iostream> using namespace std; int main() { long a, b, t, m, n, l; while (cin >> a >> b) { if (a >= b) { m = a; n = b; } else { n = a; m = b; } while (n != 0) { t = n; n = m % n; m = t; } l = a * b / m; cout << m << " " << l << endl; ...
[["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
103
4
#!ruby -nal puts "#{$F.map(&:to_i).reduce(:lcm)} #{$F.map(&:to_i).reduce(:gcd)}"
#!ruby -nal puts "#{$F.map(&:to_i).reduce(:gcd)} #{$F.map(&:to_i).reduce(:lcm)}"
[["-", 0, 557, 0, 284, 0, 652, 3, 4, 0, 753], ["+", 0, 557, 0, 284, 0, 652, 3, 4, 0, 753]]
4
33
4
# ?????§??¬?´???°????????????????????????????????????????????? def gcd(x, y) r = x % y return y if r.zero? gcd(y, r) end # ?????§??¬?????° def lcm(x, y, gcd) (x * y) / gcd end array = [] while line = gets x, y = line.split.map(&:to_i) gcd = gcd(x, y) lcm = lcm(x, y, gcd) p "#{gcd} #{lcm}" end
# ?????§??¬?´???°????????????????????????????????????????????? def gcd(x, y) r = x % y return y if r.zero? gcd(y, r) end # ?????§??¬?????° def lcm(x, y, gcd) (x * y) / gcd end array = [] while line = gets x, y = line.split.map(&:to_i) gcd = gcd(x, y) lcm = lcm(x, y, gcd) puts "#{gcd} #{lcm}" end
[["-", 0, 493, 0, 89, 8, 170, 0, 652, 735, 22], ["+", 0, 493, 0, 89, 8, 170, 0, 652, 735, 22]]
4
94
2
require 'English' def gcd(a, b) while (r = a % b) != 0 a = b b = r end b end def lcm(n, m, g) n * m / g end while gets a, b = $LAST_READ_LINE.split(/\s/).map(&:to_i).sort g = gcd(a, b) l = lcm(a, b, g) print "#{g} #{l}" end
require 'English' def gcd(a, b) while (r = a % b) != 0 a = b b = r end b end def lcm(n, m, g) (n * m) / g end while gets a, b = $LAST_READ_LINE.split(/\s/).map(&:to_i).sort g = gcd(a, b) l = lcm(a, b, g) puts "#{g} #{l}" end
[["+", 0, 735, 8, 736, 0, 738, 31, 739, 0, 24], ["+", 0, 735, 8, 736, 0, 738, 31, 739, 0, 25], ["-", 0, 493, 0, 89, 8, 170, 0, 652, 735, 22], ["+", 0, 493, 0, 89, 8, 170, 0, 652, 735, 22]]
4
96
4
class Array def gcd inject do |a, b| a * b / lcm end end def lcm inject do |a, b| a, b = b, a if a < b return a if b.zero? arr = b, a % b arr.lcm end end end while str = gets a = str.split(' ').map(&:to_i) puts "#{a.gcd} #{a.lcm}" end
class Array def lcm inject do |a, b| a * b / gcd end end def gcd inject do |a, b| a, b = b, a if a < b return a if b.zero? arr = b, a % b arr.gcd end end end while str = gets a = str.split(' ').map(&:to_i) puts "#{a.gcd} #{a.lcm}" end
[["-", 0, 493, 0, 269, 8, 736, 0, 735, 141, 22], ["+", 0, 493, 0, 269, 8, 736, 0, 735, 141, 22], ["-", 0, 652, 196, 737, 8, 736, 0, 738, 12, 22], ["+", 0, 652, 196, 737, 8, 736, 0, 738, 12, 22], ["-", 0, 652, 196, 737, 8, 736, 0, 652, 735, 22], ["+", 0, 652, 196, 737, 8, 736, 0, 652, 735, 22]]
4
92
8
#! ruby -Ku while data = gets.chomp data = gets break if data.nil? x = 1 y = 1 z = 1 gcd = [] gcda = [] gcdb = [] lcma = [] lcmb = [] a, b = data.split(' ').map(&:to_i) i = 2 while i <= a || i <= b if (a % i).zero? && (b % i).zero? # p "a=#{a} b=#{b} i=#{i} ab??????" gcd ...
while data = gets break if data.nil? x = 1 y = 1 z = 1 gcd = [] gcda = [] gcdb = [] lcma = [] lcmb = [] a, b = data.split(' ').map(&:to_i) i = 2 while i <= a || i <= b if (a % i).zero? && (b % i).zero? # p "a=#{a} b=#{b} i=#{i} ab??????" gcd << i a /= i b /= i ...
[["-", 0, 493, 0, 89, 15, 662, 12, 652, 17, 131], ["-", 0, 493, 0, 89, 15, 662, 12, 652, 735, 22], ["-", 0, 493, 0, 89, 8, 170, 0, 662, 31, 22], ["-", 0, 493, 0, 89, 8, 170, 0, 662, 0, 32], ["-", 0, 493, 0, 89, 8, 170, 0, 662, 12, 22]]
4
187
5
while line = gets a, b = line.chomp.split.map(&:to_i) gcd = a.gcd(b) lcm = a * b / c puts "#{gcd} #{lcm}" end
while line = gets a, b = line.chomp.split.map(&:to_i) gcd = a.gcd(b) lcm = a * b / gcd puts "#{gcd} #{lcm}" end
[["-", 0, 89, 8, 170, 0, 662, 12, 738, 12, 22], ["+", 0, 89, 8, 170, 0, 662, 12, 738, 12, 22]]
4
45
2
#!/usr/local/bin/ruby while line = gets rec = gets.split(' ').map(&:to_i) x = rec[0].to_i y = rec[1].to_i s = x * y loop do k = x % y x = y y = k break if k.zero? end lcm = s / x puts "#{x} #{lcm}" end
#!/usr/local/bin/ruby while line = gets rec = line.split(' ').map(&:to_i) x = rec[0].to_i y = rec[1].to_i s = x * y loop do k = x % y x = y y = k break if k.zero? end lcm = s / x puts "#{x} #{lcm}" end
[["-", 8, 170, 0, 662, 12, 652, 486, 652, 486, 22], ["+", 8, 170, 0, 662, 12, 652, 486, 652, 486, 22]]
4
77
13
#!/usr/local/bin/ruby while line = gets rec = gets.split(' ').map(&:to_i) x = rec[0] y = rec[1] s = x * y loop do k = x % y x = y y = k break if k.zero? end lcm = s / x puts "#{x} #{lcm}" end
#!/usr/local/bin/ruby while line = gets rec = line.split(' ').map(&:to_i) x = rec[0] y = rec[1] s = x * y loop do k = x % y x = y y = k break if k.zero? end lcm = s / x puts "#{x} #{lcm}" end
[["-", 8, 170, 0, 662, 12, 652, 486, 652, 486, 22], ["+", 8, 170, 0, 662, 12, 652, 486, 652, 486, 22]]
4
73
2
class Array def product(ary) temp = clone result = [] ary.each do |v| result << temp.delete_at(temp.index(v)) if temp.include?(v) end result end end # greatest common divisor(最大公約数) def gcd(i) gcd_div = prime_div2.product(i.prime_div2) gcg_div.inject { |memo, item| memo * item } end ...
class Array def product(ary) temp = clone result = [] ary.each do |v| result << temp.delete_at(temp.index(v)) if temp.include?(v) end result end end # greatest common divisor(最大公約数) def gcd(i) gcd_div = prime_div2.product(i.prime_div2) gcg_div.inject { |memo, item| memo * item } end ...
[["+", 0, 89, 8, 170, 0, 652, 3, 4, 0, 21], ["+", 8, 170, 0, 652, 3, 4, 0, 557, 0, 62], ["+", 8, 170, 0, 652, 3, 4, 0, 557, 0, 44]]
4
291
4
import sys for line in sys.stdin: a, b = list(map(int, line.split())) A, B = min(a, b), max(a, b) while True: mod = B % A if mod == 0: gcd = B / A break else: A, B = mod, A lcm = gcd * (a / gcd) * (b / gcd) print('%d %d' % (gcd, lcm))
import sys for line in sys.stdin: a, b = list(map(int, line.split())) A, B = min(a, b), max(a, b) while True: mod = B % A if mod == 0: gcd = A break else: A, B = mod, A lcm = gcd * (a / gcd) * (b / gcd) print('%d %d' % (gcd, lcm))
[["-", 64, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["-", 64, 196, 0, 1, 0, 662, 12, 657, 17, 85]]
5
98
2
import sys #最大公約数 def gcd(x, y): s = x / y r = x % y if r == 0: return y else: return gcd(y, r) #最小公倍数 def lcm(x, y): return x*y/gcd(x, y) def main(): #print ("a") for line in iter(sys.stdin.readline, ""): print (line) #tmp = sys.stdin.readline().split(" ")...
import sys #最大公約数 def gcd(x, y): s = x / y r = x % y if r == 0: return y else: return gcd(y, r) #最小公倍数 def lcm(x, y): return x*y/gcd(x, y) def main(): #print ("a") for line in iter(sys.stdin.readline, ""): #print (line) #tmp = sys.stdin.readline().split(" "...
[["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
180
4
def gcd(a,b): r = a % b while r > 0: a = b b = r r = a % b return b def lcm(a,b): return a*b / gcd(a,b) while True: try: a,b = list(map(int, input().split())) print(gcd(a,b) + " " + lcm(a,b)) except EOFError: break
def gcd(a,b): r = a % b while r > 0: a = b b = r r = a % b return b def lcm(a,b): return a*b / gcd(a,b) while True: try: a,b = list(map(int, input().split())) print(str(gcd(a,b)) + " " + str(lcm(a,b))) except EOFError: break
[["+", 3, 4, 0, 657, 31, 657, 31, 652, 63, 22], ["+", 0, 657, 31, 657, 31, 652, 3, 4, 0, 24], ["+", 31, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 0, 652, 3, 4, 0, 657, 12, 652, 63, 22], ["+", 3, 4, 0, 657, 12, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
98
6
import sys from math import gcd for line in sys.stdin: a, b = list(map(int, input().split())) print(gcd(a, b), a*b/gcd(a,b))
import sys from math import gcd for line in sys.stdin: a, b = list(map(int, line.split())) print(gcd(a, b), a*b/gcd(a,b))
[["-", 3, 4, 0, 652, 63, 319, 500, 652, 63, 22], ["-", 0, 652, 63, 319, 500, 652, 3, 4, 0, 24], ["-", 0, 652, 63, 319, 500, 652, 3, 4, 0, 25], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 500, 22]]
5
52
4
import sys from math import gcd [print("{}{}".format(gcd(k[0], k[1]), k[0] * k[1] // gcd(k[0], k[1]))) for i in sys.stdin for k in [[int(j) for j in i.split()]]]
import sys from math import gcd [print("{} {}".format(gcd(k[0], k[1]), (k[0] * k[1]) // gcd(k[0], k[1]))) for i in sys.stdin for k in [[int(j) for j in i.split()]]]
[["-", 3, 4, 0, 652, 63, 319, 500, 557, 0, 6], ["+", 3, 4, 0, 652, 63, 319, 500, 557, 0, 6], ["+", 0, 652, 3, 4, 0, 657, 31, 23, 0, 24], ["+", 0, 652, 3, 4, 0, 657, 31, 23, 0, 25]]
5
78
4
#coding: utf-8 import sys def gojo(a,b): print(a,b) if b % a == 0: return a else: return gojo(b % a, a) for line in sys.stdin: l = sorted(map(int,line.split())) a = l[0] b = l[1] print(gojo(a,b),a*b/gojo(a,b))
#coding: utf-8 import sys def gojo(a,b): if b % a == 0: return a else: return gojo(b % a, a) for line in sys.stdin: l = sorted(map(int,line.split())) a = l[0] b = l[1] print(gojo(a,b),a*b/gojo(a,b))
[["-", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 21], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
91
6
def GcdLCM(): for line in sys.stdin: x,y=map(int,line.split()) if x==None: break gcd = Gcd(x,y) lcm = int(x*y/gcd) print("{} {}".format(gcd,lcm)) def Gcd(x,y): while x!=0: x,y=y%x,x return y GcdLCM()
import sys def GcdLCM(): for line in sys.stdin: x,y=map(int,line.split()) if x==None: break gcd = Gcd(x,y) lcm = int(x*y/gcd) print("{} {}".format(gcd,lcm)) def Gcd(x,y): while x!=0: x,y=y%x,x return y GcdLCM()
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]]
5
90
2
def main(): import sys for line in sys.stdin: a, b = map(int, line.split()) c = a*b while a % b != 0: a, b = b, a%b print(b, c*b) if __name__ == '__main__': main()
def main(): import sys for line in sys.stdin: a, b = map(int, line.split()) c = a*b while a % b != 0: a, b = b, a%b print(b, c//b) if __name__ == '__main__': main()
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 48], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 676]]
5
67
2
import sys def gcd(a,b): if a%b==0: return b return gcd(b,a%b) r=[list(map(int,line.split())) for line in sys.stdin] for i in r: o=gcd(i[0],i[i]) p=i[0]*i[1]/o print(o,p)
import sys def gcd(a,b): if a%b==0: return b return gcd(b,a%b) r=[list(map(int,line.split())) for line in sys.stdin] for i in r: o=gcd(i[0],i[1]) p=i[0]*i[1]/o print(o,int(p))
[["-", 0, 662, 12, 652, 3, 4, 0, 206, 206, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 206, 206, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
89
5
# Vol0005. import sys def intinput(): a = input().split() for i in range(len(a)): a[i] = int(a[i]) return a def get_gcd(x, y): if x < y: return get_gcd(y, x) # x >= yのときはx % yを計算してyとx % yの話にする。 # ここでx % yのところが0ならばyが求める答えとなる。 if y == 0: return x return get_gcd(y, x % y) def ma...
# Vol0005. import sys def intinput(): a = input().split() for i in range(len(a)): a[i] = int(a[i]) return a def get_gcd(x, y): if x < y: return get_gcd(y, x) # x >= yのときはx % yを計算してyとx % yの話にする。 # ここでx % yのところが0ならばyが求める答えとなる。 if y == 0: return x return get_gcd(y, x % y) def ma...
[["-", 0, 652, 3, 4, 0, 657, 12, 660, 0, 22], ["+", 0, 652, 3, 4, 0, 657, 12, 660, 0, 22]]
5
191
4
import sys def gcd(a,b): if b == 0: return a else: return gcd(b,a%b) def lcm(a,b): return a*b/gcd(a,b) for s in sys.stdin: i = list(map(int,input().split())) print(gcd(*i), lcm(*i))
import sys def gcd(a,b): if b == 0: return a else: return gcd(b,a%b) def lcm(a,b): return a*b/gcd(a,b) for s in sys.stdin: i = list(map(int,s.split())) print(gcd(*i), lcm(*i))
[["-", 3, 4, 0, 652, 63, 319, 500, 652, 63, 22], ["-", 0, 652, 63, 319, 500, 652, 3, 4, 0, 24], ["-", 0, 652, 63, 319, 500, 652, 3, 4, 0, 25], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 500, 22]]
5
85
4
import sys def gcm(a, b): if a<b: a,b=b,a if (a%b==0): return b else: return gcm(b,a%b) for s in stdin: a,b=list(map(int,s.split())) c=gcm(a,b) print("%d %d" %(c,a/c*b))
import sys def gcm(a,b): if a<b: a,b=b,a if (a%b==0): return b return gcm(b,a%b) for s in sys.stdin: a,b=list(map(int,s.split())) c=gcm(a,b) print("%d %d" %(c,a/c*b))
[["-", 0, 14, 8, 196, 0, 57, 75, 76, 0, 95], ["-", 0, 14, 8, 196, 0, 57, 75, 76, 0, 102], ["+", 36, 36, 0, 656, 0, 7, 12, 319, 500, 22], ["+", 36, 36, 0, 656, 0, 7, 12, 319, 0, 131]]
5
90
4
package main import "fmt" func GCM(a, b int) int { if a < b { a, b = b, a } if b == 0 { return a } return GCM(b, a % b) } func LCM(a, b int) int { return a*b/GCM(a, b) } func main() { for { var a, b int var G, L int fmt.Scanf("%d %d", &a, &b) if a == 0 { break } G = GCM(a, b) L = LCM(a,...
package main import "fmt" func GCM(a, b int) int { if a < b { a, b = b, a } if b == 0 { return a } return GCM(b, a % b) } func LCM(a, b int) int { return a*b/GCM(a, b) } func main() { for { var a, b int var G, L int fmt.Scanf("%d %d", &a, &b) if a == 0 { break } G = GCM(a, b) L = LCM(a,...
[["+", 0, 1, 0, 2, 3, 4, 0, 429, 0, 44]]
7
157
1
<?php fscanf( STDIN, "%d", $str ); $len=strlen($str); for($i=0;$i<$len;$i++) echo $str[$len-$i-1];
<?php fscanf( STDIN, "%s", $str ); $len=strlen($str); for($i=0;$i<$len;$i++) echo $str[$len-$i-1]; ?>
[["-", 0, 613, 3, 3, 0, 28, 0, 609, 0, 610], ["+", 0, 613, 3, 3, 0, 28, 0, 609, 0, 610], ["+", 36, 36, 36, 36, 36, 36, 0, 493, 0, 611]]
6
52
3
<?php fscanf( STDIN, "%s", $str ); $rev=''; for($i=strlen($str)-1;0<=$i;$i--) $rev[]=$str[$i]; echo $rev; ?>
<?php fscanf( STDIN, "%s", $str ); $rev=''; for($i=strlen($str)-1;0<=$i;$i--) $rev.=$str[$i]; echo $rev; ?>
[["-", 0, 7, 0, 1, 0, 11, 31, 69, 0, 70], ["-", 0, 7, 0, 1, 0, 11, 31, 69, 0, 73], ["-", 0, 493, 0, 7, 0, 1, 0, 11, 0, 32], ["+", 0, 493, 0, 7, 0, 1, 0, 564, 17, 617]]
6
58
4
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] req = sc.nextLine().split(""); StringBuilder sb = new StringBuilder(); for (int i = req.length - 1; i > 0; i--) { sb.append(req[i]); } System.out.println(...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] req = sc.nextLine().split(""); StringBuilder sb = new StringBuilder(); for (int i = req.length; i > 0; i--) { sb.append(req[i - 1]); } System.out.println(...
[["-", 0, 7, 502, 503, 49, 200, 51, 16, 17, 33], ["-", 0, 7, 502, 503, 49, 200, 51, 16, 12, 499], ["+", 0, 492, 3, 4, 0, 504, 71, 16, 17, 33], ["+", 0, 492, 3, 4, 0, 504, 71, 16, 12, 499]]
3
103
4
#include <stdio.h> int main(void) { int a, b, c; long long int r, x; while (scanf("%d %d", &a, &b) != EOF) { if (a < b) { // ??´??°?????§??????????¢?????????\????????? c = a; a = b; b = c; } x = a * b; r = a % b; while (r != 0) { a = b; b = r; r = a % b; ...
#include <stdio.h> int main(void) { long long int a, b, c; long long int r, x; while (scanf("%lld %lld", &a, &b) != EOF) { if (a < b) { // ??´??°?????§??????????¢?????????\????????? c = a; a = b; b = c; } x = a * b; r = a % b; while (r != 0) { a = b; b = r; ...
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
116
6
#include <stdio.h> int lcm(int a, int b, int p) { return a * b / p; } int gcm(int a, int b) { int temp, x, k = 1; if (a < b) { temp = a; a = b; b = temp; } while (k) { x = a % b; if (x == 0) return b; a = b % x; if (a == 0) return x; b = x % a; if (b == 0) ...
#include <stdio.h> int lcm(int a, int b, int p) { return a / p * b; } int gcm(int a, int b) { int temp, x, k = 1; if (a < b) { temp = a; a = b; b = temp; } while (k) { x = a % b; if (x == 0) return b; a = b % x; if (a == 0) return x; b = x % a; if (b == 0) ...
[["-", 8, 9, 0, 37, 0, 16, 31, 16, 17, 48], ["-", 8, 9, 0, 37, 0, 16, 31, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 48], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 12, 22]]
0
184
4
#include <stdio.h> int main(void) { int a, b, r, A, B; while (scanf("%d %d", &a, &b) != EOF) { A = a; B = b; if (b > a) { a = B; b = A; } r = a % b; while (r != 0) { a = b; b = r; r = a % b; } printf("%d %d\n", b, A * B / b); } return 0; }
#include <stdio.h> int main(void) { long a, b, r, A, B; while (scanf("%ld %ld", &a, &b) != EOF) { A = a; B = b; if (b > a) { a = B; b = A; } r = a % b; while (r != 0) { a = b; b = r; r = a % b; } printf("%ld %ld\n", b, A * B / b); } return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
110
6
#include <stdio.h> /*a>b*/ int GCD(int a, int b) { int k, r, c; if (a < b) { c = a; a = b; b = c; } while (1) { k = a / b; r = a - k * b; if (r == 0) break; a = b; b = r; } return b; } int main(void) { int x, y, lcd; while (scanf("%d%d", &x, &y) != EOF) { ...
#include <stdio.h> /*a>b*/ int GCD(int a, int b) { int k, r, c; if (a < b) { c = a; a = b; b = c; } while (1) { k = a / b; r = a - k * b; if (r == 0) break; a = b; b = r; } return b; } int main(void) { int x, y, lcd; while (scanf("%d%d", &x, &y) != EOF) { ...
[["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 17, 48], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22], ["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
0
148
6
#include <stdio.h> int main() { int a, b, r, LCM; while (scanf("%d %d", &a, &b) != EOF) { LCM = a * b; if (a < b) { r = a; a = b; b = r; } r = a % b; while (r != 0) { a = b; b = r; r = a % b; } printf("%d %d\n", b, LCM / b); } return 0; }
#include <stdio.h> int main() { long int a, b, r, LCM; while (scanf("%ld %ld", &a, &b) != EOF) { LCM = a * b; if (a < b) { r = a; a = b; b = r; } r = a % b; while (r != 0) { a = b; b = r; r = a % b; } printf("%ld %ld\n", b, LCM / b); } retu...
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
107
5
#include <stdio.h> int Least_Common_Multiple(int a, int b) { int result; result = a; while (result % b != 0) { result += a; } return result; } int Greatest_Common_Factor(int a, int b) { if (a > b) { return Greatest_Common_Factor(a - b, b); } else if (a < b) { return Greatest_Common_Factor(a,...
#include <stdio.h> int Least_Common_Multiple(int a, int b) { int result; result = a; while (result % b != 0) { result += a; } return result; } int Greatest_Common_Factor(int a, int b) { if (a > b) { return Greatest_Common_Factor(a - b, b); } else if (a < b) { return Greatest_Common_Factor(a,...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
146
1
#include <stdio.h> // must be a <= b long euclid(long a, long b) { if (a == 0) return b; return euclid(b % a, a); } void swap(long *a, long *b) { long tmp; tmp = *a; *a = *b; *b = tmp; } int main() { long a, b; while (~scanf("%ld %ld", &a, &b)) { if (a > b) swap(&a, &b); long gcd = ...
#include <stdio.h> // must be a <= b long euclid(long a, long b) { if (a == 0) return b; return euclid(b % a, a); } void swap(long *a, long *b) { long tmp; tmp = *a; *a = *b; *b = tmp; } int main() { long a, b; while (~scanf("%ld %ld", &a, &b)) { if (a > b) swap(&a, &b); long gcd = ...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
142
1
#include <stdio.h> int gcd(int a, int b) { if (a % b == 0) return b; else return (gcd(b, a % b)); } int main(void) { int a, b; while (scanf("%d %d", &a, &b) > 0) { int lcm = (a * b) / gcd(a, b); if (lcm == 0) break; printf("%d %d\n", gcd(a, b), lcm); } return 0; }
#include <stdio.h> int gcd(int a, int b) { if (a % b == 0) return b; else return (gcd(b, a % b)); } int main(void) { long long int a, b; while (scanf("%lld %lld", &a, &b) > 0) { int lcm = (a * b) / gcd(a, b); if (lcm == 0) break; printf("%lld %lld\n", gcd(a, b), lcm); } return 0; }...
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
112
6
#include <stdio.h> int gcd(int m, int n) { while (m != n) { if (m > n) m = m - n; else n = n - m; } return m; } int main(void) { int m, n; while (scanf("%d %d", &m, &n) != EOF) { printf("%d\n", gcd(m, n)); int lcm = m * n / gcd(m, n); printf("%d\n", lcm); } return 0; }
#include <stdio.h> int gcd(int m, int n) { while (m != n) { if (m > n) m = m - n; else n = n - m; } return m; } int main(void) { int m, n; while (scanf("%d %d", &m, &n) != EOF) { printf("%d ", gcd(m, n)); int lcm = m / gcd(m, n) * n; printf("%d\n", lcm); } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 43, 49, 50, 51, 16, 31, 16, 17, 48], ["-", 0, 43, 49, 50, 51, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 48], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22]]
0
116
7
#include <stdio.h> long gcd_euclid(long m, long n) { long temp; while (n) { temp = m % n; m = n; n = temp; } return m; } int main() { long a, b; long temp; long gcd, lcm; while (scanf("%ld %ld", &a, &b) != EOF) { gcd = gcd_euclid(a, b); temp = a / gcd; printf("%ld %ld\n", gcd,...
#include <stdio.h> long gcd_euclid(long m, long n) { long temp; while (n) { temp = m % n; m = n; n = temp; } return m; } int main() { long a, b; long temp; long gcd, lcm; while (scanf("%ld %ld", &a, &b) != EOF) { gcd = gcd_euclid(a, b); temp = a / gcd; lcm = temp * b; prin...
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
0
107
6
#include <stdio.h> int gcd(int, int); int main(void) { int a, b; while (scanf("%d%d", &a, &b) != EOF) { printf("%d %d\n", gcd(a, b), a * b / gcd(a, b)); } return 0; } int gcd(int x, int y) { int t; if (x < y) { t = x; x = y; y = t; } if (y == 0) return x; else return gcd(y...
#include <stdio.h> int gcd(int, int); int main(void) { int a, b; while (scanf("%d%d", &a, &b) != EOF) { printf("%d %d\n", gcd(a, b), a / gcd(a, b) * b); } return 0; } int gcd(int x, int y) { int t; if (x < y) { t = x; x = y; y = t; } if (y == 0) return x; else return gcd(y...
[["-", 0, 2, 3, 4, 0, 16, 31, 16, 17, 48], ["-", 0, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 48], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
0
124
4
#include <stdio.h> int main() { int a, b, x, y; int i, j, k; while (scanf("%d %d", &a, &b) != EOF) { if (a > b) k = a % b; else k = b % a; if (k == 0) { if (a > b) x = b; else x = a; } else { for (i = 0; i <= k; i++) { if (k % i == 0) { ...
#include <stdio.h> int main() { int a, b, x, y; int i, j, k; while (scanf("%d %d", &a, &b) != EOF) { if (a > b) k = a % b; else k = b % a; if (k == 0) { if (a > b) x = b; else x = a; } else { for (i = 1; i <= k; i++) { if (k % i == 0) { ...
[["-", 75, 76, 0, 9, 0, 7, 10, 11, 12, 13], ["+", 75, 76, 0, 9, 0, 7, 10, 11, 12, 13]]
0
166
2
#include <stdio.h> int main(void) { int a, b, a2, b2; int max, min, r; while (scanf("%d %d", &a, &b) != EOF) { a2 = a; b2 = b; r = 1; while (r != 0) { r = a2 % b2; a2 = b2; max = b2; b2 = r; } min = (a * b) / max; printf("%d %d\n", max, min); } return (0...
#include <stdio.h> int main(void) { int a, b, a2, b2; int max, min, r; while (scanf("%d %d", &a, &b) != EOF) { a2 = a; b2 = b; r = 1; while (r != 0) { r = a2 % b2; a2 = b2; max = b2; b2 = r; } min = (a / max) * b; printf("%d %d\n", max, min); } return (0...
[["-", 0, 11, 12, 16, 31, 23, 0, 16, 17, 48], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22], ["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
0
109
6
#include <stdio.h> int gcd(int x, int y) { int z; do { z = x % y; x = y; y = z; } while (y != 0); return x; } int lcm(int x, int y) { int z; z = gcd(x, y); z = x * y / z; return z; } int main() { int num1, num2; while (scanf("%d %d", &num1, &num2) > 0) { printf("%d %d\n", gcd(nu...
#include <stdio.h> int gcd(int x, int y) { int z; do { z = x % y; x = y; y = z; } while (y != 0); return x; } int lcm(int x, int y) { int z; z = gcd(x, y); z = x / z * y; return z; } int main() { int num1, num2; while (scanf("%d %d", &num1, &num2) > 0) { printf("%d %d\n", gcd(nu...
[["-", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
0
132
4
#include <stdio.h> int gcd(int x, int y) { /* euclid algorithm */ int r; while ((r = x % y) != 0) x = y, y = r; return y; } int lcm(int x, int y) { if (x == 0 || y == 0) return 0; return x * y / gcd(x, y); } int main(void) { int a, b; while (scanf("%d %d", &a, &b) == 2) printf("%d %d\n", ...
#include <stdio.h> int gcd(int x, int y) { /* euclid algorithm */ int r; while ((r = x % y) != 0) x = y, y = r; return y; } int lcm(int x, int y) { if (x == 0 || y == 0) return 0; return x / gcd(x, y) * y; /* ツ静ヲツづ謁ツ掛ツつッツづゥツづ暗ャツづェツづゥ */ } int main(void) { int a, b; while (scanf("%d %...
[["-", 8, 9, 0, 37, 0, 16, 31, 16, 17, 48], ["-", 8, 9, 0, 37, 0, 16, 31, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 48], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 12, 22]]
0
130
7
#include <stdio.h> int gcd(int a, int b) { int r = a > b ? a % b : b % a; if (!r) return a > b ? b : a; else gcd(r, a > b ? b : a); } int main() { int a, b; while (~scanf("%d %d", &a, &b)) { int AnsGcd = gcd(a, b); printf("%d %d\n", AnsGcd, a * b / AnsGcd); } }
#include <stdio.h> int gcd(int a, int b) { int r = a > b ? a % b : b % a; if (!r) return a > b ? b : a; else gcd(r, a > b ? b : a); } int main() { int a, b; while (~scanf("%d %d", &a, &b)) { int AnsGcd = gcd(a, b); printf("%d %d\n", AnsGcd, a / AnsGcd * b); } }
[["-", 0, 2, 3, 4, 0, 16, 31, 16, 17, 48], ["-", 0, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 48], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
0
111
4
#include <stdio.h> int main(void) { unsigned int a, b; unsigned int l, s; int gcd, lcm; while (scanf("%d %d", &a, &b) != EOF) { l = a; s = b; if (l < s) { l = b; s = a; } while (s) { l %= s; l += s; s = l - s; l -= s; } gcd = l; lcm = a * b /...
#include <stdio.h> int main(void) { unsigned int a, b; unsigned int l, s; unsigned int gcd, lcm; while (scanf("%d %d", &a, &b) != EOF) { l = a; s = b; if (l < s) { l = b; s = a; } while (s) { l %= s; l += s; s = l - s; l -= s; } gcd = l; lcm ...
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 87], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
0
122
5
#include <stdio.h> int gcd(long long, long long); int gcd(long long a, long long b) { if (b == 0) { return a; } else { return gcd(b, a % b); }; } int main() { long long a, b, temp, gcdr, lcmr; while (scanf("%lld %lld", &a, &b) != EOF) { if (a < b) { temp = b; b = a; a = temp; ...
#include <stdio.h> int gcd(long long, long long); int gcd(long long a, long long b) { if (b == 0) { return a; } else { return gcd(b, a % b); }; } int main() { long long a, b, temp, gcdr, lcmr; while (scanf("%lld %lld", &a, &b) != EOF) { if (a < b) { temp = b; b = a; a = temp; ...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
140
1
#include <math.h> #include <stdio.h> int GCD(int x, int y) { int temp; if (x <= y) { temp = x; x = y; y = temp; } if (y == 0) return x; else { temp = y; y = x % y; x = temp; return GCD(x, y); } } int LCM(int x, int y, int gcd) { return x * y / gcd; } int main(void) { /...
#include <math.h> #include <stdio.h> int GCD(int x, int y) { int temp; if (x <= y) { temp = x; x = y; y = temp; } if (y == 0) return x; else { temp = y; y = x % y; x = temp; return GCD(x, y); } } int LCM(int x, int y, int gcd) { return x / gcd * y; } int main(void) { /...
[["-", 8, 9, 0, 37, 0, 16, 31, 16, 17, 48], ["-", 8, 9, 0, 37, 0, 16, 31, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 48], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 12, 22]]
0
157
4
#include <stdio.h> int main(void) { int a, b, gcd, lcm, tema, temb, r; while (scanf("%d %D", &a, &b) != EOF) { tema = a; temb = b; while (tema % temb != 0) { r = tema % temb; tema = temb; temb = r; } gcd = temb; lcm = a / gcd * b; printf("%d %d\n", gcd, lcm); } ret...
#include <stdio.h> int main(void) { int a, b, gcd, lcm, tema, temb, r; while (scanf("%d %d", &a, &b) != EOF) { tema = a; temb = b; while (tema % temb != 0) { r = tema % temb; tema = temb; temb = r; } gcd = temb; lcm = a / gcd * b; printf("%d %d\n", gcd, lcm); } ret...
[["-", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6]]
0
102
2
#include <stdio.h> int gcd(int, int); int main(void) { int a, b, G; for (; scanf("%d %d", &a, &b) != EOF; printf("%d %d\n", G, a * b / G)) G = gcd(a, b); return 0; } int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
#include <stdio.h> int gcd(int, int); int main(void) { int a, b, G; for (; scanf("%d %d", &a, &b) != EOF; printf("%d %d\n", G, a / G * b)) G = gcd(a, b); return 0; } int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
[["-", 26, 2, 3, 4, 0, 16, 31, 16, 17, 48], ["-", 26, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["+", 0, 7, 26, 2, 3, 4, 0, 16, 17, 48], ["+", 0, 7, 26, 2, 3, 4, 0, 16, 12, 22]]
0
97
4