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
|
|---|---|---|---|---|
#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 long int temp;
temp = b;
b = a;
a = temp;
}
long long int tempa = a, tempb = b;
r = b;
b = a;
while (r != 0) {
a = b;
b = r;
r = a % b;
}
long long ans = tempa * tempb / b;
cout << b << " " << ans << endl;
return 0;
}
|
#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) {
long long int temp;
temp = b;
b = a;
a = temp;
}
long long int tempa = a, tempb = b;
r = b;
b = a;
while (r != 0) {
a = b;
b = r;
r = a % b;
}
long long ans = tempa * tempb / b;
cout << b << " " << ans << 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], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 153
|
#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
|
#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) {
return x;
}
return gcd(y, x % y);
}
int main() {
lld a, b;
while (cin >> a >> b) {
lld n = min(a, b);
lld m = max(a, b);
lld sol = gcd(m, n);
cout << sol << endl;
cout << (n * m) / sol << endl;
}
return 0;
}
|
#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) {
return x;
}
return gcd(y, x % y);
}
int main() {
lld a, b;
while (cin >> a >> b) {
lld n = min(a, b);
lld m = max(a, b);
lld sol = gcd(m, n);
cout << sol << " " << (n * m) / sol << endl;
}
return 0;
}
|
[["-", 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
|
#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 << " " << x * y / lcm << endl;
}
}
|
#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 << lcm << " " << x * y / lcm << endl;
}
}
|
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
| 1
| 108
|
#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
|
#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 long a, unsigned long long b) {
return (a / gcd(a, b)) * b;
}
int main() {
cin >> a >> b;
cout << gcd(a, b) << " " << lcm(a, b) << endl;
return 0;
}
|
#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 long a, unsigned long long b) {
return (a / gcd(a, b)) * b;
}
int main() {
while (cin >> a >> b) {
cout << gcd(a, b) << " " << lcm(a, b) << 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], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 129
|
#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 * b1 / b;
cout << min << " " << max << endl;
}
return 0;
}
|
#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 = a1 * b1 / min;
cout << min << " " << max << endl;
}
return 0;
}
|
[["-", 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
|
#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 << endl;
}
return 0;
}
|
#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 << " " << a * b / c << endl;
}
return 0;
}
|
[["-", 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
|
#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, b));
}
return 0;
}
|
#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, b));
}
return 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]]
| 1
| 124
|
#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);
cout << n << ' ' << a * b / n << endl;
}
return 0;
}
|
#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);
cout << n << ' ' << a / n * b << endl;
}
return 0;
}
|
[["-", 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
|
#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;
}
return 0;
}
|
#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;
}
return 0;
}
|
[["-", 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
|
#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++) {
if (b % (a * i) == 0) {
cout << a * i << endl;
fl++;
} else
;
}
}
return 0;
}
|
#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++) {
if ((a * i) % b == 0) {
cout << a * i << endl;
fl++;
} else
;
}
}
return 0;
}
|
[["-", 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
|
#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
|
#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
|
#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())
break;
int g = gcd(a, b);
// printf("%d %d\n",g,a/g*b);
cout << g << a / g * b << endl;
}
return 0;
}
|
#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())
break;
int g = gcd(a, b);
// printf("%d %d\n",g,a/g*b);
cout << g << ' ' << a / g * b << endl;
}
return 0;
}
|
[["+", 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
|
#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 << 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, tmp;
if (a < b) {
tmp = b;
b = a;
a = tmp;
}
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, 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
|
#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
|
#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
|
#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, b) << " " << a * b / gcd(a, b) << endl;
}
}
|
#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, b) << " " << (long long)a * b / gcd(a, b) << endl;
}
}
|
[["+", 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
|
#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) << " " << lcm << endl;
}
}
|
#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) << " " << lcm << endl;
}
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
| 1
| 117
|
#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) {
a = b;
b = r;
r = a % b;
}
cout << b << " " << x / b << endl;
return 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 % b;
while (r != 0) {
a = b;
b = r;
r = a % b;
}
cout << b << " " << x / b << 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], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 113
|
#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
|
#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
|
#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
|
#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
|
#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;
}
if (temp > small) {
big = temp;
} else {
big = small;
small = temp;
}
}
cout << small << " " << a * b / small << endl;
}
}
|
#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;
}
if (temp > small) {
big = temp;
} else {
big = small;
small = temp;
}
}
cout << small << " " << a / small * b << 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
| 124
|
#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_gcj(a, b);
int lcm = a * b / gcj;
cout << gcj << " " << lcm << endl;
}
int main() {
int a, b;
while (cin >> a >> b) {
solve(a, b);
}
return 0;
}
|
#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_gcj(a, b);
int lcm = a / gcj * b;
cout << gcj << " " << lcm << endl;
}
int main() {
int a, b;
while (cin >> a >> b) {
solve(a, b);
}
return 0;
}
|
[["-", 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
|
#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("%d %d", GCD(m, n), LCM(m, n));
}
return 0;
}
|
#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("%d %d\n", GCD(m, n), LCM(m, n));
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 1
| 131
|
#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
|
#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 - b;
else {
b = b - a;
}
}
return a;
}
/*
int tes(int a,int b){
if(b == 0)return a;
return tes(b,a%b);
}
*/
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
|
#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 - b;
else {
b = b - a;
}
}
return a;
}
/*
int tes(int a,int b){
if(b == 0)return a;
return tes(b,a%b);
}
*/
int lcm(int a, int b) { return (a / gcd(a, b)) * b; }
|
[["-", 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
|
#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;
cout << y << " " << x << endl;
}
return 0;
}
|
#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;
cout << y << " " << x << endl;
}
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]]
| 1
| 116
|
#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
|
#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 >= b) {
d = YUK(a, b);
cout << d << '\n' << SKB(a, b, d);
} else {
d = YUK(b, a);
cout << d << '\n' << SKB(a, b, d);
}
cout << '\n';
}
return 0;
}
|
#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 >= b) {
d = YUK(a, b);
cout << d << ' ' << SKB(a, b, d);
} else {
d = YUK(b, a);
cout << d << ' ' << SKB(a, b, d);
}
cout << '\n';
}
return 0;
}
|
[["-", 0, 1, 0, 16, 31, 16, 12, 103, 0, 44], ["+", 0, 1, 0, 16, 31, 16, 12, 103, 0, 125]]
| 1
| 175
|
/* 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>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <sys/time.h>
#include <vector>
#define INF (1e9)
static const double PI(3.14159265358979323846);
static const double EPS(1e-10);
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef complex<double> P;
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
inline double now() {
struct timeval tv;
gettimeofday(&tv, NULL);
return ((double)(tv.tv_sec) + (double)(tv.tv_usec) * 1e-6);
}
#define FOR(i, b, e) for (typeof(b) i = (b); assert((i) <= (e)), i != (e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define IFC(c) \
if (c) \
continue;
#define IFB(c) \
if (c) \
break;
#define IFR(c, r) \
if (c) \
return r;
#define OPOVER(_op, _type) inline bool operator _op(const _type &t) const
#define arrsz(a) (sizeof(a) / sizeof(a[0]))
#define F first
#define S second
#define MP(a, b) make_pair(a, b)
#define SZ(a) ((ll)a.size())
#define PB(e) push_back(e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(c, it) \
for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n) (1ULL << (n))
#define BITOF(n, m) ((n) >> (m)&1)
#define RANGE(a, b, c) ((a) <= (b) && (b) <= (c))
#ifdef DEBUG_ON
#define dprt(fmt, ...) \
if (CONDITION) \
fprintf(stderr, fmt, __VA_ARGS__)
#define darr(a) \
if (CONDITION) \
copy((a), (a) + arrsz(a), ostream_iterator<int>(cerr, " ")); \
cerr << endl
#define darr_range(a, f, t) \
if (CONDITION) \
copy((a) + (f), (a) + (t), ostream_iterator<int>(cerr, " ")); \
cerr << endl
#define dvec(v) \
if (CONDITION) \
copy(ALL(v), ostream_iterator<int>(cerr, " ")); \
cerr << endl
#define darr2(a, n, m) \
if (CONDITION) \
FOR(i, 0, (n)) { darr_range((a)[i], 0, (m)); }
#define dvec2(v) \
if (CONDITION) \
FOR(i, 0, SZ(v)) { dvec((v)[i]); }
#define WAIT() \
if (CONDITION) { \
string _wait_; \
cerr << "(hit return to continue)" << endl; \
getline(cin, _wait_); \
}
#else
#define cerr \
if (0) \
cerr
#define dprt(fmt, ...)
#define darr(a)
#define darr_range(a, f, t)
#define dvec(v)
#define darr2(a, n, m)
#define dvec2(v)
#define WAIT()
#endif
/*}}}*/
ll lcm(ll a, ll b) {
if (a == 0 || b == 0) {
return 0;
}
if (a < b) {
swap(a, b);
}
ll am = a, bm = b;
while (true) {
if (am == bm) {
return am;
}
if (bm > am) {
swap(a, b);
swap(am, bm);
}
bm += b;
}
}
ll gcd(ll a, ll b) {
if (a == 0 || b == 0) {
return 0;
}
if (a < b) {
swap(a, b);
}
while (true) {
if (a % b == 0) {
return b;
}
ll buf = a;
a = b;
b = buf % b;
}
}
int main(int argc, char const *argv[]) {
ll a, b;
cin >> a >> b;
cout << gcd(a, b) << " " << lcm(a, b) << endl;
return 0;
}
|
/* 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>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <sys/time.h>
#include <vector>
#define INF (1e9)
static const double PI(3.14159265358979323846);
static const double EPS(1e-10);
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef complex<double> P;
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
inline double now() {
struct timeval tv;
gettimeofday(&tv, NULL);
return ((double)(tv.tv_sec) + (double)(tv.tv_usec) * 1e-6);
}
#define FOR(i, b, e) for (typeof(b) i = (b); assert((i) <= (e)), i != (e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define IFC(c) \
if (c) \
continue;
#define IFB(c) \
if (c) \
break;
#define IFR(c, r) \
if (c) \
return r;
#define OPOVER(_op, _type) inline bool operator _op(const _type &t) const
#define arrsz(a) (sizeof(a) / sizeof(a[0]))
#define F first
#define S second
#define MP(a, b) make_pair(a, b)
#define SZ(a) ((ll)a.size())
#define PB(e) push_back(e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(c, it) \
for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n) (1ULL << (n))
#define BITOF(n, m) ((n) >> (m)&1)
#define RANGE(a, b, c) ((a) <= (b) && (b) <= (c))
#ifdef DEBUG_ON
#define dprt(fmt, ...) \
if (CONDITION) \
fprintf(stderr, fmt, __VA_ARGS__)
#define darr(a) \
if (CONDITION) \
copy((a), (a) + arrsz(a), ostream_iterator<int>(cerr, " ")); \
cerr << endl
#define darr_range(a, f, t) \
if (CONDITION) \
copy((a) + (f), (a) + (t), ostream_iterator<int>(cerr, " ")); \
cerr << endl
#define dvec(v) \
if (CONDITION) \
copy(ALL(v), ostream_iterator<int>(cerr, " ")); \
cerr << endl
#define darr2(a, n, m) \
if (CONDITION) \
FOR(i, 0, (n)) { darr_range((a)[i], 0, (m)); }
#define dvec2(v) \
if (CONDITION) \
FOR(i, 0, SZ(v)) { dvec((v)[i]); }
#define WAIT() \
if (CONDITION) { \
string _wait_; \
cerr << "(hit return to continue)" << endl; \
getline(cin, _wait_); \
}
#else
#define cerr \
if (0) \
cerr
#define dprt(fmt, ...)
#define darr(a)
#define darr_range(a, f, t)
#define dvec(v)
#define darr2(a, n, m)
#define dvec2(v)
#define WAIT()
#endif
/*}}}*/
ll lcm(ll a, ll b) {
if (a == 0 || b == 0) {
return 0;
}
if (a < b) {
swap(a, b);
}
ll am = a, bm = b;
while (true) {
if (am == bm) {
return am;
}
if (bm > am) {
swap(a, b);
swap(am, bm);
}
bm += b;
}
}
ll gcd(ll a, ll b) {
if (a == 0 || b == 0) {
return 0;
}
if (a < b) {
swap(a, b);
}
while (true) {
if (a % b == 0) {
return b;
}
ll buf = a;
a = b;
b = buf % b;
}
}
int main(int argc, char const *argv[]) {
ll a, b;
while (cin >> a >> b) {
cout << gcd(a, b) << " " << lcm(a, b) << 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], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 695
|
//#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;
}
return 0;
}
|
[["+", 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
|
#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 * num2) / gcd;
cout << gcd << " " << lcm << "\n";
}
return 0;
}
|
#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 / gcd * num2;
cout << gcd << " " << lcm << "\n";
}
return 0;
}
|
[["-", 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
|
#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() {
int a[2];
int i = 0;
int n1, n2;
while (cin >> n1 >> n2) {
// cout << sizeof(a) / sizeof(a[0]) << endl;
cout << gcm(n1, n2) << ' ' << lcm(n1, n2) << endl;
}
return 0;
}
|
#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() {
int a[2];
int i = 0;
int n1, n2;
while (cin >> n1 >> n2) {
// cout << sizeof(a) / sizeof(a[0]) << endl;
cout << gcm(n1, n2) << ' ' << lcm(n1, n2) << endl;
}
return 0;
}
|
[["-", 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
|
#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
|
#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) {
while (a != b)
if (a > b)
a = a - b;
else
b = b - a;
return a;
}
int LCM(int a, int b) { return ((a * b) / GCD(a, b)); }
//大文字を小文字に変換
/*
for(int i=0;i<inp.size();i++)
if(inp[i]>='A' && inp[i]<='Z')
inp[i]+='a'-'A';
*/
|
#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) {
while (a != b)
if (a > b)
a = a - b;
else
b = b - a;
return a;
}
int LCM(int a, int b) { return ((a / GCD(a, b)) * b); /*(a*GCD(a,b)*b);*/ }
//大文字を小文字に変換
/*
for(int i=0;i<inp.size();i++)
if(inp[i]>='A' && inp[i]<='Z')
inp[i]+='a'-'A';
*/
|
[["-", 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
|
#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;
}
s = ai * bi / m;
cout << m << " " << s << endl;
}
return 0;
}
|
#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;
} else
a = a % b;
}
s = ai * bi / m;
cout << m << " " << s << endl;
}
return 0;
}
|
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 87], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
| 1
| 121
|
#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_SUCCESS;
}
|
#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;
}
return EXIT_SUCCESS;
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
| 1
| 93
|
#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;
i = i + 1;
}
for (j = 0; j < i; j++) {
while (x[j] % y[j] != 0) {
z[j] = x[j] % y[j];
x[j] = y[j];
y[j] = z[j];
}
gcd[j] = y[j];
lcm[j] = x2[j] * y2[j] / gcd[j];
printf("%d %d\n", gcd[j], lcm[j]);
}
return 0;
}
|
#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)
break;
i = i + 1;
}
for (j = 0; j < i; j++) {
while (x[j] % y[j] != 0) {
z[j] = x[j] % y[j];
x[j] = y[j];
y[j] = z[j];
}
gcd[j] = y[j];
lcm[j] = x2[j] * (y2[j] / gcd[j]);
printf("%d %d\n", gcd[j], lcm[j]);
}
return 0;
}
|
[["+", 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
|
#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;
;
break;
}
}
}
return 0;
}
|
#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) / l << endl;
;
break;
}
}
}
return 0;
}
|
[["-", 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
|
#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;
}
while (r != 0) {
r = a % b;
a = b;
b = r; // aが最大公約数
}
return a;
}
int main() {
long int x, y;
long int gcd, lcm;
cin >> x >> y;
gcd = Gcm(x, y);
x = x / gcd;
y = y / gcd;
lcm = x * y * gcd;
cout << gcd << " " << lcm << endl;
return 0;
}
|
#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;
}
while (r != 0) {
r = a % b;
a = b;
b = r; // aが最大公約数
}
return a;
}
int main() {
long int x, y;
long int gcd, lcm;
while (cin >> x >> y) {
gcd = Gcm(x, y);
x = x / gcd;
y = y / gcd;
lcm = x * y * gcd;
cout << gcd << " " << lcm << 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], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 150
|
#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
|
#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;
}
return 0;
}
|
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 87]]
| 1
| 96
|
#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
|
#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;
}
miner = min(a2, b2);
cout << miner << endl;
cout << a / miner * b << endl;
}
return 0;
}
|
#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;
}
miner = min(a2, b2);
cout << miner << " ";
cout << a / miner * b << endl;
}
return 0;
}
|
[["-", 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
|
#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 {
n = 0;
m = b1;
}
while (n != 0) {
int buf = n;
n = m % n;
m = buf;
}
printf("%d\n", m);
while (b1 != b2) {
if (b1 < b2)
b1 += buf1[i];
else
b2 += buf2[i];
}
printf("%d\n", b1);
}
return 0;
}
|
#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 {
n = 0;
m = b1;
}
while (n != 0) {
int buf = n;
n = m % n;
m = buf;
}
printf("%d ", m);
while (b1 != b2) {
if (b1 < b2)
b1 += buf1[i];
else
b2 += buf2[i];
}
printf("%d\n", b1);
}
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]]
| 1
| 205
|
#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() {
int a, b, c, x, y;
cin >> a >> b;
cout << gcd(a, b) << " " << lcm(a, b) << endl;
return 0;
}
|
#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() {
int a, b, c, x, y;
while (cin >> a >> b) {
cout << gcd(a, b) << " " << lcm(a, b) << 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], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 156
|
#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 (a <= 0 or a > 2000000000 or b <= 0 or b > 2000000000) {
cin >> a >> b;
}
if (a > 0 and b > 0) {
cout << gcd(a, b) << " " << lcm(a, b) << "\n";
}
}
return 0;
}
|
#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;
while (a <= 0 or a > 2000000000 or b <= 0 or b > 2000000000) {
cin >> a >> b;
}
if (a > 0 and b > 0) {
cout << gcd(a, b) << " " << lcm(a, b) << "\n";
}
}
return 0;
}
|
[["+", 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
|
#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
|
#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)
break;
x = MIN(x, y);
y = r;
}
aby.push_back(a);
aby.push_back(b);
aby.push_back(MIN(a, b));
}
list<long>::iterator it = aby.begin();
while (it != aby.end()) {
a = *it, it++;
b = *it, it++;
y = *it;
cout << y << " " << (a * b) / y << endl;
it++;
}
return 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)
break;
x = MIN(x, y);
y = r;
}
aby.push_back(a);
aby.push_back(b);
aby.push_back(MIN(x, y));
}
list<long>::iterator it = aby.begin();
while (it != aby.end()) {
a = *it, it++;
b = *it, it++;
y = *it;
cout << y << " " << (a * b) / y << endl;
it++;
}
return 0;
}
|
[["-", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22]]
| 1
| 212
|
#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;
}
return 0;
}
|
#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;
}
return 0;
}
|
[["+", 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
|
#!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
|
# ?????§??¬?´???°?????????????????????????????????????????????
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
|
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
|
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
|
#! 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 << i
a /= i
b /= i
redo
elsif (a % i).zero?
# p "a=#{a} b=#{b} i=#{i} a??????"
gcda << i
a /= i
redo
elsif (b % i).zero?
# p "a=#{a} b=#{b} i=#{i} b??????"
gcdb << i
b /= i
redo
end
i += 1
# p "#{a} #{b}"
end
gcda.each do |i|
x *= i
end
gcdb.each do |i|
y *= i
end
gcd.each do |i|
z *= i
end
# puts "#{gcd} #{x} #{y} #{z} #{x*y*z}"
puts "#{z} #{x * y * z}"
end
|
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
redo
elsif (a % i).zero?
# p "a=#{a} b=#{b} i=#{i} a??????"
gcda << i
a /= i
redo
elsif (b % i).zero?
# p "a=#{a} b=#{b} i=#{i} b??????"
gcdb << i
b /= i
redo
end
i += 1
# p "#{a} #{b}"
end
gcda.each do |i|
x *= i
end
gcdb.each do |i|
y *= i
end
gcd.each do |i|
z *= i
end
# puts "#{gcd} #{x} #{y} #{z} #{x*y*z}"
puts "#{z} #{x * y * z}"
end
|
[["-", 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
|
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
|
#!/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
|
#!/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
|
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
# least common multiple(最小公倍数)
def lcm(i)
lcm_div = prime_div2 + i.prime_div2
lcm_div -= prime_div2.product(i.prime_div2)
lcm_div.inject { |memo, item| memo * item }
end
# エラトステネスの篩いによる素数列の生成
def eratosthenes(n)
list = Array.new(n - 1).map.with_index { |_i, k| k + 2 }
result = [1]
while list.last >= result.last**2
p = list.shift
result << p
list.delete_if { |v| (v % p).zero? }
end
result.shift
result += list
end
# 素因数分解して[2, 2, 2, 3]の様に返す。
def prime_div
k = self
c = 0
result = []
eratosthenes(n / 2).each do |i|
c = 0
next unless (k % i).zero?
while (k % i).zero?
k /= i
result << k
end
end
result
end
while line = gets
imput = line.chomp.split.map(&:to_i)
print imput[0].gcd(imput[1]), ' ', imput[0].lcm(imput[1])
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
# least common multiple(最小公倍数)
def lcm(i)
lcm_div = prime_div2 + i.prime_div2
lcm_div -= prime_div2.product(i.prime_div2)
lcm_div.inject { |memo, item| memo * item }
end
# エラトステネスの篩いによる素数列の生成
def eratosthenes(n)
list = Array.new(n - 1).map.with_index { |_i, k| k + 2 }
result = [1]
while list.last >= result.last**2
p = list.shift
result << p
list.delete_if { |v| (v % p).zero? }
end
result.shift
result += list
end
# 素因数分解して[2, 2, 2, 3]の様に返す。
def prime_div
k = self
c = 0
result = []
eratosthenes(n / 2).each do |i|
c = 0
next unless (k % i).zero?
while (k % i).zero?
k /= i
result << k
end
end
result
end
while line = gets
imput = line.chomp.split.map(&:to_i)
print imput[0].gcd(imput[1]), ' ', imput[0].lcm(imput[1]), "\n"
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
|
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
|
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(" ")
#print ("b")
tmp = line.split(" ")
a = int(tmp[0])
b = int(tmp[1])
#print ("a="+str(a))
#print ("b="+str(b))
#b = sys.stdin.readline()
#print ("d")
if a > b:
c = a
d = b
else:
c = b
d = a
print (str(gcd(c, d)) + " " + str(int(lcm(c,d))))
#tmp = sys.stdin.readline()
#if len(tmp) == 1:
# break
#else:
# tmp = tmp.split(" ")
#print ("exit")
if __name__ == "__main__":
main()
|
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(" ")
#print ("b")
tmp = line.split(" ")
a = int(tmp[0])
b = int(tmp[1])
#print ("a="+str(a))
#print ("b="+str(b))
#b = sys.stdin.readline()
#print ("d")
if a > b:
c = a
d = b
else:
c = b
d = a
print (str(gcd(c, d)) + " " + str(int(lcm(c,d))))
#tmp = sys.stdin.readline()
#if len(tmp) == 1:
# break
#else:
# tmp = tmp.split(" ")
#print ("exit")
if __name__ == "__main__":
main()
|
[["-", 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
|
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
|
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
|
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
|
#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
|
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
|
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
|
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
|
# 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 main():
data = []
lines = sys.stdin.readlines()
for line in lines:
data.append(line.split())
N = len(data)
for i in range(N):
a = int(data[i][0]); b = int(data[i][1])
gcd = get_gcd(a, b)
lcm = (a // gcd) * b
print('%d %d' % (a, b))
if __name__ == "__main__":
main()
|
# 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 main():
data = []
lines = sys.stdin.readlines()
for line in lines:
data.append(line.split())
N = len(data)
for i in range(N):
a = int(data[i][0]); b = int(data[i][1])
gcd = get_gcd(a, b)
lcm = (a // gcd) * b
print('%d %d' % (gcd, lcm))
if __name__ == "__main__":
main()
|
[["-", 0, 652, 3, 4, 0, 657, 12, 660, 0, 22], ["+", 0, 652, 3, 4, 0, 657, 12, 660, 0, 22]]
| 5
| 191
|
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
|
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
|
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, b)
fmt.Printf("%d %d", G, L)
}
}
|
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, b)
fmt.Printf("%d %d\n", G, L)
}
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 429, 0, 44]]
| 7
| 157
|
<?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
|
<?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
|
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(sb.toString());
}
}
|
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(sb.toString());
}
}
|
[["-", 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
|
#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;
}
printf("%d %d\n", b, x / b);
}
return (0);
}
|
#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;
r = a % b;
}
printf("%lld %lld\n", b, x / b);
}
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
| 116
|
#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)
return a;
}
}
int main(void) {
int n, a, b, c, i, p;
while (scanf("%d %d", &a, &b) != EOF) {
p = gcm(a, b);
printf("%d %d\n", p, lcm(a, b, p));
}
return 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)
return a;
}
}
int main(void) {
int n, a, b, c, i, p;
while (scanf("%d %d", &a, &b) != EOF) {
p = gcm(a, b);
printf("%d %d\n", p, lcm(a, b, p));
}
return 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
|
#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
|
#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) {
lcd = (x * y) / GCD(x, y);
printf("%d %d\n", GCD(x, y), lcd);
}
return 0;
}
|
#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) {
lcd = x / GCD(x, y) * y; /* avoid calculate x*y(very large number) */
printf("%d %d\n", GCD(x, y), lcd);
}
return 0;
}
|
[["-", 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
|
#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);
}
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
| 107
|
#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, b - a);
} else {
return a;
}
}
int main(void) {
int a, b;
while (scanf("%d %d", &a, &b) != EOF) {
printf("%d %d", Greatest_Common_Factor(a, b), Least_Common_Multiple(a, b));
}
return 0;
}
|
#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, b - a);
} else {
return a;
}
}
int main(void) {
int a, b;
while (scanf("%d %d", &a, &b) != EOF) {
printf("%d %d\n", Greatest_Common_Factor(a, b),
Least_Common_Multiple(a, b));
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 0
| 146
|
#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 = euclid(a, b);
long lcm = a * b / gcd;
printf("%ld %ld", gcd, lcm);
}
return 0;
}
|
#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 = euclid(a, b);
long lcm = a * b / gcd;
printf("%ld %ld\n", gcd, lcm);
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 0
| 142
|
#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
|
#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
|
#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, lcm);
}
return 0;
}
|
#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;
printf("%ld %ld\n", gcd, lcm);
}
return 0;
}
|
[["+", 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
|
#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, x % 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, x % 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
|
#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) {
j = k / i;
if (a % j == 0 && b % j == 0) {
x = j;
break;
}
}
}
}
y = a * (b / x);
printf("%d %d\n", x, y);
}
return 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) {
j = k / i;
if (a % j == 0 && b % j == 0) {
x = j;
break;
}
}
}
}
y = a * (b / x);
printf("%d %d\n", x, y);
}
return 0;
}
|
[["-", 75, 76, 0, 9, 0, 7, 10, 11, 12, 13], ["+", 75, 76, 0, 9, 0, 7, 10, 11, 12, 13]]
| 0
| 166
|
#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
|
#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(num1, num2), lcm(num1, num2));
}
return 0;
}
|
#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(num1, num2), lcm(num1, num2));
}
return 0;
}
|
[["-", 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
|
#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", gcd(a, b), lcm(a, b));
return 0;
}
|
#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 %d", &a, &b) == 2)
printf("%d %d\n", gcd(a, b), lcm(a, b));
return 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
| 130
|
#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
|
#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 / gcd;
printf("%d %d\n", gcd, lcm);
}
return (0);
}
|
#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 = a / gcd * b;
printf("%d %d\n", gcd, lcm);
}
return (0);
}
|
[["+", 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
|
#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;
};
gcdr = gcd(a, b);
lcmr = a * b / gcdr;
printf("%lld %lld", gcdr, lcmr);
};
return 0;
}
|
#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;
};
gcdr = gcd(a, b);
lcmr = a * b / gcdr;
printf("%lld %lld\n", gcdr, lcmr);
};
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 0
| 140
|
#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) {
// int n, i;
int a, b;
while (scanf("%d %d", &a, &b) == 2) {
printf("%d %d\n", GCD(a, b), LCM(a, b, GCD(a, b)));
}
return 0;
}
|
#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) {
// int n, i;
int a, b;
while (scanf("%d %d", &a, &b) == 2) {
printf("%d %d\n", GCD(a, b), LCM(a, b, GCD(a, b)));
}
return 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
| 157
|
#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);
}
return 0;
}
|
#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);
}
return 0;
}
|
[["-", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 102
|
#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
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.