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
|
|---|---|---|---|---|---|
if __name__ == '__main__':
nums = []
for line in sys.stdin:
if line == "\n":
break
else :
nums.append([int(item) for item in input().split(" ")])
for n in nums:
sum = n[0] + n[1]
print(len(str(sum)))
|
import sys
if __name__ == '__main__':
nums = []
for line in sys.stdin:
if line == "\n":
break
else :
nums.append([int(item) for item in line.split(" ")])
for n in nums:
sum = n[0] + n[1]
print(len(str(sum)))
|
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["-", 0, 659, 12, 652, 63, 319, 500, 652, 63, 22], ["-", 12, 652, 63, 319, 500, 652, 3, 4, 0, 24], ["-", 12, 652, 63, 319, 500, 652, 3, 4, 0, 25], ["+", 0, 658, 0, 659, 12, 652, 63, 319, 500, 22]]
| 5
| 78
| 6
|
while True:
try:
a,b = map(int, input().split())
except:
break
print(len(str(a+b)))
|
while True:
try:
a,b = map(int,input().split())
except:
exit()
print(len(str(a+b)))
|
[["-", 0, 246, 0, 671, 0, 196, 0, 93, 0, 94], ["+", 0, 671, 0, 196, 0, 1, 0, 652, 63, 22], ["+", 0, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
| 5
| 36
| 4
|
import fileinput
if __name__ == "__main__":
for line in fileinput.input():
v = line.split(" ")
print(sum([int(i) for i in v]))
|
import fileinput
if __name__ == "__main__":
for line in fileinput.input():
v = line.split(" ")
print(len(str(sum([int(i) for i in v]))))
|
[["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 3, 4, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
| 5
| 44
| 6
|
while True:
a,b=map(int,input().split())
digit=(a+b)
digit2=str(digit)
print(len(digit2))
break
|
try:
while True:
a,b=map(int,input().split())
digit=(a+b)
digit2=str(digit)
print(len(digit2))
except:
pass
|
[["+", 36, 36, 36, 36, 0, 656, 0, 246, 0, 247], ["+", 36, 36, 36, 36, 0, 656, 0, 246, 0, 102], ["-", 0, 656, 0, 52, 8, 196, 0, 93, 0, 94], ["+", 36, 36, 0, 656, 0, 246, 0, 671, 0, 672], ["+", 36, 36, 0, 656, 0, 246, 0, 671, 0, 102], ["+", 0, 246, 0, 671, 0, 196, 0, 674, 0, 675]]
| 5
| 40
| 6
|
import sys
a = [print(len(sum(map(int, line.split())))) for line in sys.stdin]
|
import sys
a = [print(len(str(sum(map(int, line.split()))))) for line in sys.stdin]
|
[["+", 3, 4, 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
| 31
| 5
|
import sys
a = [print(len(sum(map(int, line.split())))) for line in sys.stdin]
|
import sys
[print(len(str(sum(map(int, line.split()))))) for line in sys.stdin]
|
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 3, 4, 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
| 31
| 5
|
while True:
try:
x = list(map(int, input().split(' ')))
n = x[0] * x[1]
print(len(str(n)))
except EOFError:
break
|
while True:
try:
x = list(map(int, input().split(' ')))
n = x[0] + x[1]
print(len(str(n)))
except EOFError:
break
|
[["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 48], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 72]]
| 5
| 50
| 2
|
import math
while t == 0:
try:
x,y=[int(i) for i in input().split()]
except:
break
else:
a = int (math.log10(x + y) + 1)
print(a)
|
import math
t = 0
while t == 0:
try:
x,y=[int(i) for i in input().split()]
except:
break
else:
a = int (math.log10(x + y) + 1)
print(a)
|
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]]
| 5
| 53
| 3
|
import math
lst = []
while True:
try:
a, b = map(int, input().split())
lst.append(int(math.log(10, a+b))+1)
except EOFError:
for i in lst:
print(i)
break
|
import math
lst = []
while True:
try:
a, b = map(int, input().split())
lst.append(int(math.log10(a+b))+1)
except EOFError:
for i in lst:
print(i)
break
|
[["-", 31, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 31, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["-", 31, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["-", 31, 652, 3, 4, 0, 652, 3, 4, 0, 21]]
| 5
| 60
| 4
|
for line in sys.stdin:
s=sum([int(num) for num in line.split(' ')])
print(len(str(s)))
|
import sys
for line in sys.stdin:
s=sum([int(num) for num in line.split(' ')])
print(len(str(s)))
|
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]]
| 5
| 39
| 2
|
import sys
for line in sys.stdin:
a, b = map(str, line.split())
print(len(a+b))
|
import sys
for line in sys.stdin:
a, b = map(int, line.split())
print(len(str(a+b)))
|
[["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 3, 4, 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
| 32
| 5
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
//??????????????°?¨????
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str;
int a, b, GCD, LCM;
while ((str = br.readLine()) != null) {
String[] num = str.split(" ", 0);
//?????????
a = Integer.parseInt(num[0]);
b = Integer.parseInt(num[1]);
//???????¨????
GCD = euclid(a, b);
LCM = a * b / GCD;
System.out.println(GCD + " " + LCM);
}
}
//??????????????????
static int euclid(int u, int v) {
int temp;
if (u < v) {
temp = u;
u = v;
v = temp;
}
if (v < 1)
return -1;
if (u % v == 0)
return v;
return euclid(v, u % v);
}
}
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
//??????????????°?¨????
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str;
int a, b, GCD, LCM;
while ((str = br.readLine()) != null) {
String[] num = str.split(" ", 0);
//?????????
a = Integer.parseInt(num[0]);
b = Integer.parseInt(num[1]);
//???????¨????
GCD = euclid(a, b);
LCM = a / GCD * b;
System.out.println(GCD + " " + LCM);
}
}
//??????????????????
static int euclid(int u, int v) {
int temp;
if (u < v) {
temp = u;
u = v;
v = temp;
}
if (v < 1)
return -1;
if (u % v == 0)
return v;
return euclid(v, u % v);
}
}
|
[["-", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22]]
| 3
| 225
| 4
|
import java.io.*;
// import java.math.BigDecimal;
// import java.lang.reflect.Array;
// import java.util.Arrays;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
try (BufferedReader br =
new BufferedReader(new InputStreamReader(System.in))) {
String line = br.readLine();
do {
String[] in = line.split(" ", 0);
//???????????????????¨????
int a = Integer.parseInt(in[0]);
int b = Integer.parseInt(in[1]);
while (a != b) {
if (a > b) {
a = a - b;
} else {
b = b - a;
}
}
int out2 = Integer.parseInt(in[0]) * Integer.parseInt(in[1]) / a;
System.out.println(a + " " + out2);
//???????????§??????
line = br.readLine();
} while (line != null);
} catch (Exception e) {
// TODO: handle exception
System.exit(0);
}
}
}
|
import java.io.*;
// import java.math.BigDecimal;
// import java.lang.reflect.Array;
// import java.util.Arrays;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
try (BufferedReader br =
new BufferedReader(new InputStreamReader(System.in))) {
String line = br.readLine();
do {
String[] in = line.split(" ", 0);
//???????????????????¨????
int a = Integer.parseInt(in[0]);
int b = Integer.parseInt(in[1]);
while (a != b) {
if (a > b) {
a = a - b;
} else {
b = b - a;
}
}
long out2 = Long.parseLong(in[0]) * Long.parseLong(in[1]) / a;
System.out.println(a + " " + out2);
//???????????§??????
line = br.readLine();
} while (line != null);
} catch (Exception e) {
// TODO: handle exception
System.exit(0);
}
}
}
|
[["-", 0, 82, 8, 196, 0, 503, 39, 506, 0, 507], ["+", 0, 82, 8, 196, 0, 503, 39, 506, 0, 96], ["-", 49, 200, 51, 16, 31, 16, 31, 492, 500, 22], ["+", 49, 200, 51, 16, 31, 16, 31, 492, 500, 22], ["-", 49, 200, 51, 16, 31, 16, 31, 492, 141, 22], ["+", 49, 200, 51, 16, 31, 16, 31, 492, 141, 22], ["-", 49, 200, 51, 16, 31, 16, 12, 492, 500, 22], ["+", 49, 200, 51, 16, 31, 16, 12, 492, 500, 22], ["-", 49, 200, 51, 16, 31, 16, 12, 492, 141, 22], ["+", 49, 200, 51, 16, 31, 16, 12, 492, 141, 22]]
| 3
| 204
| 10
|
public class Main {
public static void main(String[] args) {
// TODO ?????????????????????????????????????????????
java.util.Scanner sc = new java.util.Scanner(System.in);
int a = 1;
int b = 1;
while (sc.hasNext()) {
a = sc.nextInt();
b = sc.nextInt();
}
System.out.println(gcd(a, b) + " " + lcm(a, b));
}
public static int gcd(int a, int b) {
int r;
int max = Math.max(a, b);
int mini = Math.min(a, b);
do {
r = max % mini; // max = q*mini + r , mini > r
max = mini;
mini = r;
} while (r != 0);
return max;
}
public static int lcm(int a, int b) {
int d = gcd(a, b);
return a / d * b;
}
}
|
public class Main {
public static void main(String[] args) {
// TODO ?????????????????????????????????????????????
java.util.Scanner sc = new java.util.Scanner(System.in);
int a = 1;
int b = 1;
while (sc.hasNext()) {
a = sc.nextInt();
b = sc.nextInt();
System.out.println(gcd(a, b) + " " + lcm(a, b));
}
}
public static int gcd(int a, int b) {
int r;
int max = Math.max(a, b);
int mini = Math.min(a, b);
do {
r = max % mini; // max = q*mini + r , mini > r
max = mini;
mini = r;
} while (r != 0);
return max;
}
public static int lcm(int a, int b) {
int d = gcd(a, b);
return a / d * b;
}
}
|
[["-", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46]]
| 3
| 196
| 2
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String name = br.readLine();
int num;
int compare;
int[] a = new int[2];
int i = 0;
int tmp;
int x, y;
while (true) {
try {
StringTokenizer st = new StringTokenizer(name, " ");
while (st.hasMoreTokens()) {
a[i] = Integer.parseInt(st.nextToken());
i++;
}
i = 0;
if (a[0] > a[1]) {
x = a[0];
y = a[1];
} else {
x = a[1];
y = a[0];
}
while ((tmp = x % y) != 0) {
tmp = x % y;
x = y;
y = tmp;
}
System.out.println(y + " " + a[0] / y * a[1] / y);
a[0] = 0;
a[1] = 0;
x = 0;
y = 0;
tmp = 0;
name = br.readLine();
}
catch (Exception e) {
System.exit(0);
}
}
}
}
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String name = br.readLine();
int num;
int compare;
int[] a = new int[2];
int i = 0;
int tmp;
int x, y;
while (true) {
try {
StringTokenizer st = new StringTokenizer(name, " ");
while (st.hasMoreTokens()) {
a[i] = Integer.parseInt(st.nextToken());
i++;
}
i = 0;
if (a[0] > a[1]) {
x = a[0];
y = a[1];
} else {
x = a[1];
y = a[0];
}
while ((tmp = x % y) != 0) {
tmp = x % y;
x = y;
y = tmp;
}
System.out.println(y + " " + a[0] / y * a[1]);
a[0] = 0;
a[1] = 0;
x = 0;
y = 0;
tmp = 0;
name = br.readLine();
}
catch (Exception e) {
System.exit(0);
}
}
}
}
|
[["-", 0, 492, 3, 4, 0, 16, 12, 16, 17, 85], ["-", 0, 492, 3, 4, 0, 16, 12, 16, 12, 22]]
| 3
| 303
| 2
|
/* package whatever; // don't place package name! */
import java.util.Scanner;
class Main {
public static void main(String[] args) throws java.lang.Exception {
Scanner cin = new Scanner(System.in);
while (cin.hasNext()) {
int a = cin.nextInt();
int b = cin.nextInt();
int gcd = GCD(a, b);
int lcm = a * b / gcd;
System.out.println(gcd + " " + lcm);
}
}
public static int GCD(int a, int b) {
if (a % b != 0) {
return (GCD(b, a % b));
} else {
return (b);
}
}
}
|
/* package whatever; // don't place package name! */
import java.util.Scanner;
class Main {
public static void main(String[] args) throws java.lang.Exception {
Scanner cin = new Scanner(System.in);
while (cin.hasNext()) {
int a = cin.nextInt();
int b = cin.nextInt();
int gcd = GCD(a, b);
int lcm = a / gcd * b;
System.out.println(gcd + " " + lcm);
}
}
private static int GCD(int a, int b) {
if (a % b != 0) {
return (GCD(b, a % b));
} else {
return (b);
}
}
}
|
[["-", 0, 503, 49, 200, 51, 16, 31, 16, 17, 48], ["-", 0, 503, 49, 200, 51, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 16, 17, 48], ["+", 8, 196, 0, 503, 49, 200, 51, 16, 12, 22], ["-", 0, 235, 8, 498, 0, 195, 0, 494, 0, 259], ["+", 0, 235, 8, 498, 0, 195, 0, 494, 0, 261]]
| 3
| 146
| 6
|
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int num1, num2, gc1, gc2, lc1, lc2;
while (sc.hasNextInt()) {
num1 = sc.nextInt();
num2 = sc.nextInt();
if (num1 >= num2) {
gc1 = num1;
gc2 = num2;
lc1 = num1;
lc2 = num2;
} else {
gc1 = num2;
gc2 = num1;
lc1 = num2;
lc2 = num1;
} // xx1?????§?????????xx2????°??????????????????£??\???
int GCD, LCM;
while (gc1 % gc2 != 0) {
GCD = gc1 % gc2;
gc1 = gc2;
gc2 = GCD;
}
LCM = (lc1 * lc2) / gc2;
System.out.println(gc2 + " " + LCM);
}
sc.close();
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
long num1, num2, gc1, gc2, lc1, lc2;
while (sc.hasNextInt()) {
num1 = sc.nextInt();
num2 = sc.nextInt();
if (num1 >= num2) {
gc1 = num1;
gc2 = num2;
lc1 = num1;
lc2 = num2;
} else {
gc1 = num2;
gc2 = num1;
lc1 = num2;
lc2 = num1;
} // xx1?????§?????????xx2????°??????????????????£??\???
long GCD, LCM;
while (gc1 % gc2 != 0) {
GCD = gc1 % gc2;
gc1 = gc2;
gc2 = GCD;
}
LCM = (lc1 * lc2) / gc2;
System.out.println(gc2 + " " + LCM);
}
sc.close();
}
}
|
[["-", 0, 195, 8, 196, 0, 503, 39, 506, 0, 507], ["+", 0, 195, 8, 196, 0, 503, 39, 506, 0, 96], ["-", 0, 52, 8, 196, 0, 503, 39, 506, 0, 507], ["+", 0, 52, 8, 196, 0, 503, 39, 506, 0, 96]]
| 3
| 178
| 4
|
import java.util.*;
public class Main {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
while (sc.hasNext()) {
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(gcd(a, b) + " " + lcm(a, b));
}
}
//最大公約数gcdを求める
static int gcd(int a, int b) {
int temp;
while ((temp = a % b) != 0) {
a = b;
b = temp;
}
return b;
}
//最小公倍数lcmを求める
static int lcm(int a, int b) {
int temp;
int c = a;
int d = b;
while ((temp = a % b) != 0) {
a = b;
b = temp;
}
return (c * d) / b;
}
}
|
import java.util.*;
public class Main {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
while (sc.hasNext()) {
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(gcd(a, b) + " " + lcm(a, b));
}
}
//最大公約数gcdを求める
static int gcd(int a, int b) {
int temp;
while ((temp = a % b) != 0) {
a = b;
b = temp;
}
return b;
}
//最小公倍数lcmを求める
static long lcm(int a, int b) {
int temp;
long c = a;
long d = b;
while ((temp = a % b) != 0) {
a = b;
b = temp;
}
return (c * d) / b;
}
}
|
[["-", 0, 235, 8, 498, 0, 195, 39, 506, 0, 507], ["+", 0, 235, 8, 498, 0, 195, 39, 506, 0, 96], ["-", 0, 195, 8, 196, 0, 503, 39, 506, 0, 507], ["+", 0, 195, 8, 196, 0, 503, 39, 506, 0, 96]]
| 3
| 187
| 6
|
import java.util.*;
public class Main {
void run() {
Scanner sc = new Scanner(System.in);
for (; sc.hasNext();) {
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(gcd(a, b) + " " + lcm(a, b));
}
}
int gcd(int a, int b) {
if (a == 0)
return b;
return gcd(b, a % b);
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
public static void main(String[] args) { new Main().run(); }
}
|
import java.util.*;
public class Main {
void run() {
Scanner sc = new Scanner(System.in);
for (; sc.hasNext();) {
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(gcd(a, b) + " " + lcm(a, b));
}
}
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; }
public static void main(String[] args) { new Main().run(); }
}
|
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 57, 64, 37, 0, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 22]]
| 3
| 158
| 4
|
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
long a = sc.nextInt();
long b = sc.nextInt();
long smaller = a;
long larger = b;
if (b < smaller) {
smaller = b;
larger = a;
}
long aa = a;
long bb = b;
while (bb != 0) {
long tmp = bb;
bb = aa % bb;
aa = tmp;
}
long lcm = (a * b) / aa;
System.out.println(a + " " + lcm);
}
}
}
|
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
long a = sc.nextInt();
long b = sc.nextInt();
long smaller = a;
long larger = b;
if (b < smaller) {
smaller = b;
larger = a;
}
long aa = a;
long bb = b;
while (bb != 0) {
long tmp = bb;
bb = aa % bb;
aa = tmp;
}
long lcm = (a * b) / aa;
System.out.println(aa + " " + lcm);
}
}
}
|
[["-", 0, 492, 3, 4, 0, 16, 31, 16, 31, 22], ["+", 0, 492, 3, 4, 0, 16, 31, 16, 31, 22]]
| 3
| 147
| 2
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
long a = sc.nextLong();
long b = sc.nextLong();
System.out.printf(gcd(a, b) + " " + a / gcd(a, b) * b);
}
}
public static long gcd(long a, long b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
}
// by TTTMongolia 11/05/2012
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
long a = sc.nextLong();
long b = sc.nextLong();
System.out.println(gcd(a, b) + " " + a / gcd(a, b) * b);
}
}
public static long gcd(long a, long b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
}
// by TTTMongolia 11/05/2012
|
[["-", 0, 52, 8, 196, 0, 1, 0, 492, 141, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 492, 141, 22]]
| 3
| 126
| 2
|
import java.util.Scanner;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
doIt();
}
public static void doIt() {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
long a = sc.nextLong();
long b = sc.nextLong();
System.out.println(getGCD(a, b) + " " + getLCM(a, b));
}
// System.out.println(getGCD(8, 6));;
// System.out.println(getGCD(50000000, 30000000));;
// System.out.println(getGCD(3, 1));;
}
// a >= b
public static long getGCD(long a, long b) {
long ta = a, tb = b;
while (true) {
if (ta == tb) {
break;
}
while (ta > tb) {
tb += b;
}
while (tb > ta) {
ta += a;
}
// System.out.println("ta = " + ta + ", tb = " + tb);
}
return ta;
}
// a >= b
public static long getLCM(long a, long b) {
long p, q, r;
p = a;
q = b;
r = b;
long tmp;
do {
tmp = r;
r = p % q;
p = q;
q = r;
} while (r != 0);
return tmp;
}
}
|
import java.util.Scanner;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
doIt();
}
public static void doIt() {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
long a = sc.nextLong();
long b = sc.nextLong();
System.out.println(getLCM(a, b) + " " + getGCD(a, b));
}
// System.out.println(getGCD(8, 6));;
// System.out.println(getGCD(50000000, 30000000));;
// System.out.println(getGCD(3, 1));;
}
// a >= b
public static long getGCD(long a, long b) {
long ta = a, tb = b;
while (true) {
if (ta == tb) {
break;
}
while (ta > tb) {
tb += b;
}
while (tb > ta) {
ta += a;
}
// System.out.println("ta = " + ta + ", tb = " + tb);
}
return ta;
}
// a >= b
public static long getLCM(long a, long b) {
long p, q, r;
p = a;
q = b;
r = b;
long tmp;
do {
tmp = r;
r = p % q;
p = q;
q = r;
} while (r != 0);
return tmp;
}
}
|
[["-", 3, 4, 0, 16, 31, 16, 31, 492, 141, 22], ["+", 3, 4, 0, 16, 31, 16, 31, 492, 141, 22], ["-", 0, 492, 3, 4, 0, 16, 12, 492, 141, 22], ["+", 0, 492, 3, 4, 0, 16, 12, 492, 141, 22]]
| 3
| 239
| 4
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
while (stdIn.hasNext()) {
long numA = stdIn.nextLong();
long numB = stdIn.nextLong();
long GCD = getGCD(numA, numB); //最大公約数
long LCM = getLCM(numA, numB); //最小公倍数
System.out.println(GCD + " " + LCM);
}
}
//++++++++++++++++++++++++++++++++++++++++++++++++++
//最大公約数(GCD)取得メソッド
//++++++++++++++++++++++++++++++++++++++++++++++++++
public static long getGCD(long numA, long numB) {
//以下、ユークリッドの互除法
if (numA < numB) {
long temp = numA;
numA = numB;
numB = temp;
}
long r;
while (0 != numB) {
r = numA % numB;
numB = r;
}
long GCD = numA;
return GCD;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++
//最小公倍数(LCM)取得メソッド
//++++++++++++++++++++++++++++++++++++++++++++++++++
public static long getLCM(long numA, long numB) {
long LCM = 0L;
LCM = numA / getGCD(numA, numB) * numB;
return LCM;
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
while (stdIn.hasNext()) {
long numA = stdIn.nextLong();
long numB = stdIn.nextLong();
long GCD = getGCD(numA, numB); //最大公約数
long LCM = getLCM(numA, numB); //最小公倍数
System.out.println(GCD + " " + LCM);
}
}
//++++++++++++++++++++++++++++++++++++++++++++++++++
//最大公約数(GCD)取得メソッド
//++++++++++++++++++++++++++++++++++++++++++++++++++
public static long getGCD(long numA, long numB) {
//以下、ユークリッドの互除法
if (numA > numB) {
long temp = numA;
numA = numB;
numB = temp;
}
long r;
while (0 != numB) {
r = numA % numB;
numA = numB;
numB = r;
}
long GCD = numA;
return GCD;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++
//最小公倍数(LCM)取得メソッド
//++++++++++++++++++++++++++++++++++++++++++++++++++
public static long getLCM(long numA, long numB) {
long LCM = 0L;
LCM = numA / getGCD(numA, numB) * numB;
return LCM;
}
}
|
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 17, 18], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 17, 47], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 17, 32]]
| 3
| 204
| 6
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
if (sc.hasNextInt()) { // EOFについたらifが成り立たずbreakする
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(
LCM(a, b) + " " +
GCD(a, b)); //公約数と公倍数を求めるメソッドは別に用意する
} else {
break;
}
}
}
static int GCD(int a, int b) {
int gcd = 1;
if (a == b) {
return a;
}
int gcdSup = Math.max(a, b) / 2; // aとbの大きい方の半分
for (int i = 2; i <= gcdSup; i++) {
if (a % i == 0) { // iがaの因数である場合
if (b % i == 0) { // iがbの因数である場合
gcd = i; // iを新しい公約数として更新
}
}
}
return gcd;
}
static int LCM(int a, int b) {
int lcm = -1;
int aTimes = a;
int bTimes = b;
while (true) {
while (aTimes < bTimes) {
aTimes = aTimes + a * ((bTimes - aTimes) /
a); // aの倍数がbの倍数に追い付くか抜くまで増やす
if (aTimes == bTimes) {
return aTimes;
} else {
aTimes += a;
} //これをするとaの倍数がbの倍数を超える
}
while (bTimes < aTimes) {
bTimes = bTimes + b * ((aTimes - bTimes) /
b); // bの倍数がaの倍数に追い付くか抜くまで増やす
if (aTimes == bTimes) {
return aTimes;
} else {
bTimes += b;
}
}
if (aTimes == bTimes) {
return aTimes;
}
if (aTimes > 2000000000) {
break;
}
}
return lcm;
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
if (sc.hasNextInt()) { // EOFについたらifが成り立たずbreakする
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(
GCD(a, b) + " " +
LCM(a, b)); //公約数と公倍数を求めるメソッドは別に用意する
} else {
break;
}
}
}
static int GCD(int a, int b) {
int gcd = 1;
if (a == b) {
return a;
}
int gcdSup = Math.max(a, b) / 2; // aとbの大きい方の半分
for (int i = 2; i <= gcdSup; i++) {
if (a % i == 0) { // iがaの因数である場合
if (b % i == 0) { // iがbの因数である場合
gcd = i; // iを新しい公約数として更新
}
}
}
return gcd;
}
static int LCM(int a, int b) {
int lcm = -1;
int aTimes = a;
int bTimes = b;
while (true) {
while (aTimes < bTimes) {
aTimes = aTimes + a * ((bTimes - aTimes) /
a); // aの倍数がbの倍数に追い付くか抜くまで増やす
if (aTimes == bTimes) {
return aTimes;
} else {
aTimes += a;
} //これをするとaの倍数がbの倍数を超える
}
while (bTimes < aTimes) {
bTimes = bTimes + b * ((aTimes - bTimes) /
b); // bの倍数がaの倍数に追い付くか抜くまで増やす
if (aTimes == bTimes) {
return aTimes;
} else {
bTimes += b;
}
}
if (aTimes == bTimes) {
return aTimes;
}
if (aTimes > 2000000000) {
break;
}
}
return lcm;
}
}
|
[["-", 3, 4, 0, 16, 31, 16, 31, 492, 141, 22], ["+", 3, 4, 0, 16, 31, 16, 31, 492, 141, 22], ["-", 0, 492, 3, 4, 0, 16, 12, 492, 141, 22], ["+", 0, 492, 3, 4, 0, 16, 12, 492, 141, 22]]
| 3
| 335
| 4
|
package Volume0;
import java.io.IOException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
Scanner scan = new Scanner(System.in);
while (scan.hasNext()) {
long a = scan.nextLong();
long b = scan.nextLong();
long gcd = divide(a, b);
long lcm = a * b / gcd;
System.out.println(gcd + " " + lcm);
}
}
public static long divide(long a, long b) {
long r;
if (a < b) {
long temp = b;
b = a;
a = temp;
}
r = a % b;
return r == 0 ? a : divide(b, r);
}
}
|
import java.io.IOException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
Scanner scan = new Scanner(System.in);
while (scan.hasNext()) {
long a = scan.nextLong();
long b = scan.nextLong();
long gcd = divide(a, b);
long lcm = a * b / gcd;
System.out.println(gcd + " " + lcm);
}
}
public static long divide(long a, long b) {
long r;
if (a < b) {
long temp = b;
b = a;
a = temp;
}
r = a % b;
return r == 0 ? b : divide(b, r);
}
}
|
[["-", 36, 36, 36, 36, 0, 493, 0, 501, 0, 483], ["-", 36, 36, 36, 36, 0, 493, 0, 501, 0, 22], ["-", 36, 36, 36, 36, 0, 493, 0, 501, 0, 35], ["-", 0, 195, 8, 196, 0, 37, 0, 510, 64, 22], ["+", 0, 195, 8, 196, 0, 37, 0, 510, 64, 22]]
| 3
| 166
| 5
|
#include <stdio.h>
int GCD(int m, int n);
int main(void) {
int a, b, gcd, lcm;
while (scanf("%d %d", &a, &b) != EOF) {
gcd = GCD(a, b);
lcm = gcd * (a / gcd) * (b / gcd);
printf("%d %d", gcd, lcm);
}
}
int GCD(int m, int n) {
int remain = 0;
while (n != 0) {
remain = m % n;
m = n;
n = remain; /*讓m一直是被除數的身分;n一直是除數的身分 */
}
return m;
}
|
#include <stdio.h>
int GCD(int m, int n);
int main(void) {
int a, b, gcd, lcm;
/*printf("Insert two numbers\n");*/
while (scanf("%d %d", &a, &b) != EOF) {
gcd = GCD(a, b);
lcm = gcd * (a / gcd) * (b / gcd);
/*printf("GCD and LCM are:\n");*/
printf("%d %d\n", gcd, lcm);
}
return 0;
}
int GCD(int m, int n) {
int remain = 0;
while (n != 0) {
remain = m % n;
m = n;
n = remain;
}
return m;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 35]]
| 0
| 125
| 4
|
#include <stdio.h>
int main() {
long long int a, b, i, x, y, t;
while (scanf("%lld%lld", &a < &b) == 2) {
x = a;
y = b;
while (b) {
t = a % b;
a = b;
b = t;
}
printf("%lld %lld\n", a, (x * y) / a);
}
return 0;
}
|
#include <stdio.h>
int main() {
long long int a, b, i, x, y, t;
while (scanf("%lld%lld", &a, &b) == 2) {
x = a;
y = b;
while (b) {
t = a % b;
a = b;
b = t;
}
printf("%lld %lld\n", a, (x * y) / a);
}
return 0;
}
|
[["-", 0, 16, 31, 2, 3, 4, 0, 16, 17, 18], ["+", 15, 23, 0, 16, 31, 2, 3, 4, 0, 21]]
| 0
| 91
| 2
|
#include <stdio.h>
int cal_gcd(int x, int y) {
int r = x % y;
while (r != 0) {
x = y;
y = r;
r = x % y;
}
return y;
}
int main() {
int a, b, gcd, lcm;
while (scanf("%d %d", &a, &b) != EOF) {
gcd = cal_gcd(a, b);
lcm = a * b / gcd;
printf("%d %d\n", gcd, lcm);
}
return 0;
}
|
#include <stdio.h>
int cal_gcd(int x, int y) {
int r = x % y;
while (r != 0) {
x = y;
y = r;
r = x % y;
}
return y;
}
int main() {
int a, b, gcd, lcm;
while (scanf("%d %d", &a, &b) != EOF) {
gcd = cal_gcd(a, b);
lcm = (a / gcd) * b;
printf("%d %d\n", gcd, lcm);
}
return 0;
}
|
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["-", 0, 1, 0, 11, 12, 16, 31, 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
| 111
| 6
|
#include <stdio.h>
int main() {
int a, b, m, n, temp, amari;
while (scanf("%d %d", &a, &b) == EOF) {
if (a < b) {
temp = a;
a = b;
b = temp;
}
m = a;
n = b;
amari = m % n;
while (amari != 0) {
m = n;
n = amari;
amari = m % n;
}
printf("%d %d\n", n, a * (b / n));
}
return 0;
}
|
#include <stdio.h>
int main() {
int a, b, m, n, temp, amari;
while (scanf("%d %d", &a, &b) != EOF) {
if (a < b) {
temp = a;
a = b;
b = temp;
}
m = a;
n = b;
amari = m % n;
while (amari != 0) {
m = n;
n = amari;
amari = m % n;
}
printf("%d %d\n", n, a * (b / n));
}
return 0;
}
|
[["-", 8, 9, 0, 52, 15, 23, 0, 16, 17, 60], ["+", 8, 9, 0, 52, 15, 23, 0, 16, 17, 79]]
| 0
| 117
| 2
|
#include <stdio.h>
main() {
int a, b, c, x, y;
while (scanf("%d %d", &a, &b) != EOF) {
x = a, y = b;
while (b != 0) {
c = a % b;
a = b;
b = c;
}
printf("%d %d\n", a, x * y / a);
}
return 0;
}
|
#include <stdio.h>
main() {
long long int a, b, c, x, y;
while (scanf("%lld %lld", &a, &b) != EOF) {
x = a, y = b;
while (b != 0) {
c = a % b;
a = b;
b = c;
}
printf("%lld %lld\n", a, x * y / a);
}
return 0;
}
|
[["+", 0, 30, 0, 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
| 87
| 6
|
#include <stdio.h>
long gcd(long a, long b) {
if (b == 0) {
return (a);
}
return (gcd(b, a % b));
}
long lcm(long a, long b) { return (a / gcd(a, b) * b); }
int main(void) {
long a, b;
scanf("%ld %ld", &a, &b);
printf("%ld %ld\n", gcd(a, b), lcm(a, b));
return (0);
}
|
#include <stdio.h>
long gcd(long a, long b) {
if (b == 0) {
return (a);
}
return (gcd(b, a % b));
}
long lcm(long a, long b) { return (a / gcd(a, b) * b); }
int main(void) {
long a, b;
while (scanf("%ld %ld", &a, &b) != EOF)
printf("%ld %ld\n", gcd(a, b), lcm(a, b));
return (0);
}
|
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 23, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 52, 15, 23, 0, 16, 17, 79], ["+", 8, 9, 0, 52, 15, 23, 0, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 52, 15, 23, 0, 25]]
| 0
| 115
| 6
|
#include <stdio.h>
int main(void) {
long int a, b, l = 1;
int i;
while (scanf("%ld %ld", &a, &b) != EOF) {
for (i = 2; 0 != (a / i) * (b / i); i++) {
if (a % i + b % i == 0) {
l *= i;
a /= i;
b /= i;
i--;
}
}
printf("%ld %ld\n", l, l * a * b);
}
return 0;
}
|
#include <stdio.h>
int main(void) {
long int a, b, l = 1;
int i;
while (scanf("%ld %ld", &a, &b) != EOF) {
for (i = 2; 0 != (a / i) * (b / i); i++) {
if (a % i + b % i == 0) {
l *= i;
a /= i;
b /= i;
i--;
}
}
printf("%ld %ld\n", l, l * a * b);
l = 1;
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 0
| 114
| 4
|
#include <stdio.h>
int gcd(int a, int b) {
if (a == 0)
return b;
else
return gcd(b % a, a);
}
int main() {
int a, b, m, n;
while (scanf("%d %d", &a, &b) != EOF) {
m = gcd(a, b);
n = a * b * m;
printf("%d %d\n", m, n);
}
return 0;
}
|
#include <stdio.h>
int gcd(int a, int b) {
if (a == 0)
return b;
else
return gcd(b % a, a);
}
int main() {
int a, b, m, n;
while (scanf("%d %d", &a, &b) != EOF) {
m = gcd(a, b);
n = a / m * b;
printf("%d %d\n", m, n);
}
return 0;
}
|
[["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 85], ["+", 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
| 99
| 12
|
#include <stdio.h>
int main() {
int x, y;
while (scanf("%d %d", &x, &y) != EOF) {
int tmp, m, n;
if (x > y) {
m = x;
n = y;
} else {
m = y;
n = x;
}
while (n != 0) {
tmp = n;
n = m % n;
m = tmp;
}
printf("%d %d\n", m, x * y / m);
}
return 0;
}
|
#include <stdio.h>
int main() {
int x, y;
while (scanf("%d %d", &x, &y) != EOF) {
int tmp, m, n;
if (x > y) {
m = x;
n = y;
} else {
m = y;
n = x;
}
while (n != 0) {
tmp = n;
n = m % n;
m = tmp;
}
printf("%d %d\n", m, x / m * y);
}
return 0;
}
|
[["-", 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
| 107
| 4
|
#include <stdio.h>
int main(void) {
int a, b, i, gcm = 1, lcm = 1;
while (scanf("%d %d", &a, &b) != EOF) {
gcm = 1;
lcm = 1;
for (i = 2; (i <= a) || (i <= b); i++) {
if (a % i == 0 && b % i == 0) {
gcm *= i;
}
if (a % i == 0 || b % i == 0) {
lcm *= i;
}
if (a % i == 0) {
a = a / i;
}
if (b % i == 0) {
b = b / i;
}
if (a % i == 0 || b % i == 0) {
i = 2;
}
}
printf("%d %d", gcm, lcm);
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int a, b, i, gcm = 1, lcm = 1;
while (scanf("%d %d", &a, &b) != EOF) {
gcm = 1;
lcm = 1;
for (i = 2; (i <= a) || (i <= b); i++) {
if (a % i == 0 && b % i == 0) {
gcm *= i;
}
if (a % i == 0 || b % i == 0) {
lcm *= i;
}
if (a % i == 0) {
a = a / i;
}
if (b % i == 0) {
b = b / i;
}
if (a % i == 0 || b % i == 0) {
i = 1;
}
}
printf("%d %d\n", gcm, lcm);
}
return 0;
}
|
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 0
| 180
| 3
|
#include <stdio.h>
int main(void) {
int a, b, c, d;
int i, j, temp;
while (scanf("%d %d", &a, &b) != EOF) {
c = a;
d = b;
for (i = 1, j = 1; 1;) {
if (a * j > b * i) {
i++;
} else if (a * j < b * i) {
j++;
} else if (a * j == b * i) {
break;
}
}
for (; 1;) {
if (c % d != 0) {
temp = c % d;
c = d;
d = temp;
} else {
break;
}
}
printf("%d %d\n", a * j, d);
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int a, b, c, d;
int i, j, temp;
while (scanf("%d %d", &a, &b) != EOF) {
c = a;
d = b;
for (i = 1, j = 1; 1;) {
if (a * j > b * i) {
i++;
} else if (a * j < b * i) {
j++;
} else if (a * j == b * i) {
break;
}
}
for (; 1;) {
if (c % d != 0) {
temp = c % d;
c = d;
d = temp;
} else {
break;
}
}
printf("%d %d\n", d, a * j);
}
return 0;
}
|
[["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
| 0
| 167
| 4
|
#include <stdio.h>
int gcd(int a, int b);
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 a, int b) {
int tmp, tmp2;
if (a < b) {
tmp = a;
a = b;
b = tmp;
}
while (a % b != 0) {
tmp2 = b;
b = a % b;
a = tmp2;
}
return (b);
}
|
#include <stdio.h>
int gcd(int a, int b);
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 a, int b) {
int tmp, tmp2;
if (a < b) {
tmp = a;
a = b;
b = tmp;
}
while (a % b != 0) {
tmp2 = b;
b = a % b;
a = tmp2;
}
return (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
| 139
| 4
|
#include <stdio.h>
int main(void) {
long int a, b, ax, bx, min, max, test_min[200], test_max[200];
int i, j = 0;
while (scanf("%d %d", &a, &b) != EOF) {
if (a < 0)
a = -a;
if (b < 0)
b = -b;
ax = a;
bx = b;
while (1) {
if (a > b) {
b = b + bx;
} else if (b > a) {
a = a + ax;
} else {
break;
}
}
min = a;
max = (ax * bx) / min;
test_min[j] = min;
test_max[j] = max;
j++;
}
for (i = 0; i <= j; i++) {
printf("%d %d\r\n", test_max[i], test_min[i]);
}
return 0;
}
|
#include <stdio.h>
int main(void) {
long int a, b, ax, bx, min, max, test_min[200], test_max[200];
int i, j = 0;
while (scanf("%d %d", &a, &b) != EOF) {
if (a < 0)
a = -a;
if (b < 0)
b = -b;
ax = a;
bx = b;
while (1) {
if (a > b) {
b = b + bx;
} else if (b > a) {
a = a + ax;
} else {
break;
}
}
min = a;
max = (ax * bx) / min;
test_min[j] = min;
test_max[j] = max;
j++;
}
for (i = 0; i < j; i++) {
printf("%d %d\r\n", test_max[i], test_min[i]);
}
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
| 0
| 197
| 2
|
t, a;
main(b) {
for (; t = ~scanf("%d%d", &a, &b); printf("%d %d\n", t, a / t * b))
t = g(a, b);
}
g(x, y) { y ? g(y, x % y) : x; }
|
t, a;
main(b) {
for (; t = ~scanf("%d%d", &a, &b); printf("%d %d\n", t, a / t * b))
g(a, b);
}
g(x, y) { return t = y ? g(y, x % y) : x; }
|
[["-", 8, 9, 0, 7, 8, 1, 0, 11, 31, 22], ["-", 8, 9, 0, 7, 8, 1, 0, 11, 17, 32], ["+", 36, 36, 0, 30, 0, 9, 0, 37, 0, 38], ["+", 0, 30, 0, 9, 0, 37, 0, 11, 31, 22], ["+", 0, 30, 0, 9, 0, 37, 0, 11, 17, 32]]
| 0
| 76
| 9
|
#include <stdio.h>
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int main(void) {
int a, b;
scanf("%d %d", &a, &b);
printf("%d %d\n", gcd(a, b), lcm(a, b));
return 0;
}
|
#include <stdio.h>
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int main(void) {
int a, b;
while (~scanf("%d %d", &a, &b)) {
printf("%d %d\n", gcd(a, b), lcm(a, b));
}
return 0;
}
|
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 23, 0, 24], ["+", 8, 9, 0, 52, 15, 23, 0, 91, 17, 92], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 23, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 0
| 100
| 7
|
#include <stdio.h>
int main(void) {
long a, b, c, d, e;
long g;
long long r;
while (scanf("%d%d", &d, &e) == 2) {
if (d != e) {
a = d > e ? d : e;
b = d > e ? e : d;
r = a * b;
while (a % b != 0) {
c = b;
b = a % b;
a = c;
}
g = b;
} else {
r = d * e;
g = d;
}
printf("%ld %llsd\n", g, r / g);
}
return 0;
}
|
#include <stdio.h>
int main(void) {
long long a, b, c, d, e;
long long g;
long long r;
while (scanf("%lld%lld", &d, &e) == 2) {
if (d != e) {
a = d > e ? d : e;
b = d > e ? e : d;
r = a * b;
while (a % b != 0) {
c = b;
b = a % b;
a = c;
}
g = b;
} else {
r = d * e;
g = d;
}
printf("%lld %lld\n", g, r / g);
}
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
| 138
| 6
|
#include <stdio.h>
int gcd(int a, int b);
int main(void) {
int a, b, c, GCD, lcm;
while (scanf("%d %d", &a, &b) != EOF) {
GCD = gcd(a, b);
lcm = (a * b) / GCD;
printf("%d %d\n", GCD, lcm);
}
return (0);
}
int gcd(int a, int b) {
if (b == 0)
return (a);
return (gcd(b, a % b));
}
|
#include <stdio.h>
int gcd(int a, int b);
int main(void) {
int a, b, c, GCD, lcm;
while (scanf("%d %d", &a, &b) != EOF) {
GCD = gcd(a, b);
lcm = a / GCD * b;
printf("%d %d\n", GCD, lcm);
}
return (0);
}
int gcd(int a, int b) {
if (b == 0)
return (a);
return (gcd(b, a % b));
}
|
[["-", 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
| 119
| 6
|
// 0-0003 直角三角形の判定
/*
#include<iostream>
using namespace std;
int main(){
int n;
int a,b,c;
cin >> n;
for(int i=0; i<n; i++){
cin >> a >> b >> c;
a*=a; b*=b; c*=c;
if(a == b+c || b == a+c || c == a+b)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
*/
/*
//0-0004 連立一次方程式
#include<stdio.h>
int main(){
double a1,b1,e1,a2,b2,e2;
double x,y;
while(scanf("%lf %lf %lf %lf %lf %lf",&a1,&b1,&e1,&a2,&b2,&e2) != EOF){
x = e1*b2 / (a1*b2 - b1*a2) - b1*e2 / (a1*b2 - b1*a2);
y = e2*a1 / (a1*b2 - b1*a2) - e1*a2 / (a1*b2 - b1*a2);
printf("%.3f %.3f\n",x,y);
}
return 0;
}
*/
// 0-0005 最大公約数 最小公倍数
#include <stdio.h>
void swap(int *a, int *b) {
int temp;
temp = *a;
*a = *b;
*b = temp;
}
int GCD(int n, int m) {
if (m > n)
swap(&n, &m);
if (m == 0)
return n;
else
return GCD(m, n % m);
}
int main() {
int a, b, c;
while (scanf("%d %d", &a, &b) != EOF)
c = GCD(a, b);
printf("%d %d\n", c, (a / c) * b);
return 0;
}
|
#include <stdio.h>
void swap(int *a, int *b) {
int temp;
temp = *a;
*a = *b;
*b = temp;
}
int GCD(int n, int m) {
if (m > n)
swap(&n, &m);
if (m == 0)
return n;
else
return GCD(m, n % m);
}
int main() {
int a, b, c;
while (scanf("%d %d", &a, &b) != EOF) {
c = GCD(a, b);
printf("%d %d\n", c, (a / c) * b);
}
return 0;
}
|
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 0
| 144
| 2
|
#include <stdio.h>
int main(void) {
int x, y, a, b, i;
while (scanf("%d%d", &x, &y) != EOF) {
a = x;
b = y;
while (1) {
if (a > b)
a -= b;
if (a < b)
b -= a;
if (a == b)
break;
}
printf("%d %d\n", a, x * y / a);
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int x, y, a, b, i;
while (scanf("%d%d", &x, &y) != EOF) {
a = x;
b = y;
while (1) {
if (a > b)
a -= b;
if (a < b)
b -= a;
if (a == b)
break;
}
printf("%d %d\n", a, x * (y / a));
}
return 0;
}
|
[["+", 0, 2, 3, 4, 0, 16, 12, 23, 0, 24], ["+", 0, 2, 3, 4, 0, 16, 12, 23, 0, 25]]
| 0
| 100
| 2
|
#include <stdio.h>
int gcd(int x, int y) {
if (y == 0)
return x;
else
return gcd(y, x % y);
}
int main() {
int x, y;
while (scanf("%d %d") != EOF)
printf("%d %d\n", gcd(x, y), x / gcd(x, y) * y);
return 0;
}
|
#include <stdio.h>
int gcd(int x, int y) {
if (y == 0)
return x;
else
return gcd(y, x % y);
}
int main() {
int x, y;
while (scanf("%d %d", &x, &y) != EOF)
printf("%d %d\n", gcd(x, y), x / gcd(x, y) * y);
return 0;
}
|
[["+", 15, 23, 0, 16, 31, 2, 3, 4, 0, 21], ["+", 0, 16, 31, 2, 3, 4, 0, 66, 17, 67], ["+", 0, 16, 31, 2, 3, 4, 0, 66, 28, 22]]
| 0
| 84
| 6
|
#include <stdio.h>
int main(void) {
int a, r, x, y, box;
while (scanf("%d %d", &x, &y) != EOF) {
a = x * y;
if (x < y) {
box = x;
x = y;
y = box;
}
r = x % y;
while (r != 0) {
x = y;
y = r;
r = x % y;
}
printf("%d %d\n", y, a / y);
}
return 0;
}
|
#include <stdio.h>
int main(void) {
long long int a, r, x, y, box;
while (scanf("%lld %lld", &x, &y) != EOF) {
a = x * y;
if (x < y) {
box = x;
x = y;
y = box;
}
r = x % y;
while (r != 0) {
x = y;
y = r;
r = x % y;
}
printf("%lld %lld\n", y, a / y);
}
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
| 110
| 6
|
#include <stdio.h>
int main() {
int i, a, b, p, q, r;
while (scanf("%d", &a) != EOF) {
scanf("%d", &b);
p = a;
q = b;
for (i = 0; i < 1000; i++) {
r = p % q;
if (r == 0)
break;
p = q;
q = r;
}
printf("%d %d", q, a * b / q);
}
return 0;
}
|
#include <stdio.h>
int main() {
long i, a, b, p, q, r;
while (scanf("%ld", &a) != EOF) {
scanf("%ld", &b);
p = a;
q = b;
for (i = 0; i < 1000; i++) {
r = p % q;
if (r == 0)
break;
p = q;
q = r;
}
printf("%ld %ld\n", q, a * b / q);
}
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, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 0
| 110
| 9
|
#include <stdio.h>
int main(void) {
int a, b, r, x, tmp;
char str[100];
for (; fgets(str, sizeof(str), stdin) != NULL;) {
sscanf(str, "%d %d", &a, &b);
x = a * b;
if (a < b) {
tmp = a;
a = b;
b = tmp;
}
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 a, b, r, x, tmp;
char str[100];
for (; fgets(str, sizeof(str), stdin) != NULL;) {
sscanf(str, "%lld %lld", &a, &b);
x = a * b;
if (a < b) {
tmp = a;
a = b;
b = tmp;
}
r = a % b;
while (r != 0) {
a = b;
b = r;
r = a % b;
}
printf("%lld %lld\n", b, x / b);
}
return 0;
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 132
| 7
|
#include <stdio.h>
int main() {
int a, b, n, m, r;
while (scanf("%d%d", &a, &b) != EOF) {
if (a > b) {
n = a;
m = b;
} else {
n = b;
m = a;
}
while ((r = n % m) != 0) {
n = m;
m = r;
}
printf("%d %d\n", m, a * b / m);
}
return (0);
}
|
#include <stdio.h>
int main() {
long long a, b, n, m, r;
while (scanf("%lld%lld", &a, &b) != EOF) {
if (a > b) {
n = a;
m = b;
} else {
n = b;
m = a;
}
while ((r = n % m) != 0) {
n = m;
m = r;
}
printf("%lld %lld\n", m, a * b / m);
}
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
| 108
| 7
|
#include <stdio.h>
int main(void) {
long long int a, b;
long long int m, n;
long long int tmp;
while (scanf("%lld %lld", &a, &b) != EOF) {
m = (a > b) ? a : b;
n = (a > b) ? b : a;
while (m % n != 0) {
tmp = m % n;
m = n;
n = tmp;
}
printf("%lld %lld", n, a * b / n);
}
return 0;
}
|
#include <stdio.h>
int main(void) {
long long int a, b;
long long int m, n;
long long int tmp;
while (scanf("%lld %lld", &a, &b) != EOF) {
m = (a > b) ? a : b;
n = (a > b) ? b : a;
while (m % n != 0) {
tmp = m % n;
m = n;
n = tmp;
}
printf("%lld %lld\n", n, a * b / n);
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 0
| 113
| 1
|
#include <stdio.h>
int getGCD(int a, int b) {
int i, temp, r;
if (a < b) {
temp = a;
a = b;
b = temp;
}
/*
for(i = a; i > 0 ; i--){
if(a % i == 0 && b % i == 0)
return i;
}*/
r = a % b;
while (r != 0) {
a = b;
b = r;
r = a % b;
}
return b;
}
int getLCM(int a, int b) {
int lcm;
int gcd = getGCD(a, b);
lcm = (a * b) / gcd;
return lcm;
}
int main(void) {
int a, b;
while (scanf("%d %d", &a, &b) != EOF) {
printf("%d %d\n", getGCD(a, b), getLCM(a, b));
}
return 0;
}
|
#include <stdio.h>
int getGCD(int a, int b) {
int i, temp, r;
if (a < b) {
temp = a;
a = b;
b = temp;
}
r = a % b;
while (r != 0) {
a = b;
b = r;
r = a % b;
}
return b;
}
long getLCM(int a, int b) {
long lcm;
int gcd = getGCD(a, b);
lcm = ((long)a * b) / gcd;
return lcm;
}
int main(void) {
int a, b;
while (scanf("%d %d", &a, &b) != EOF) {
printf("%d %lu\n", getGCD(a, b), getLCM(a, b));
}
return 0;
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 0, 30, 0, 14, 39, 86, 0, 96], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 12, 16, 31, 23, 0, 16, 31, 74, 0, 24], ["+", 0, 16, 31, 74, 39, 77, 39, 86, 0, 96], ["+", 12, 16, 31, 23, 0, 16, 31, 74, 0, 25], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 165
| 9
|
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main(void) {
int a, b;
cin >> a >> b;
int res = gcd(a, b);
cout << gcd(a, b) << " " << a / res * b << endl;
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main(void) {
int a, b;
while (cin >> a >> b) {
int res = gcd(a, b);
cout << gcd(a, b) << " " << a / res * 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
| 89
| 6
|
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
int gcd = __gcd(a, b);
cout << gcd << " " << a / gcd * b << endl;
}
|
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
int a, b;
while (cin >> a >> b) {
int gcd = __gcd(a, b);
cout << gcd << " " << a / gcd * b << endl;
}
}
|
[["+", 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
| 51
| 6
|
#include <iostream>
using namespace std;
int func1(int a, int b) {
while (a != b) {
if (a > b)
a -= b;
else
b -= a;
}
return a;
}
int func2(const int a, const int b) {
int a2 = a, b2 = b;
while (a2 != b2) {
if (a2 > b2)
b2 += b;
else
a2 += a;
}
return a2;
}
int main() {
int a, b;
while (cin >> a >> b) {
cout << func1(a, b) << " " << func2(a, b);
}
return 0;
}
|
#include <iostream>
using namespace std;
int func1(int a, int b) {
while (a != b) {
if (a > b)
a -= b;
else
b -= a;
}
return a;
}
int func2(const int a, const int b) {
int a2 = a, b2 = b;
while (a2 != b2) {
if (a2 > b2)
b2 += b;
else
a2 += a;
}
return a2;
}
int main() {
int a, b;
while (cin >> a >> b) {
cout << func1(a, b) << " " << func2(a, 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
| 135
| 2
|
#include <iostream>
#include <utility>
using namespace std;
int gcn(int a, int b) {
if (a < b) {
swap(a, b);
}
while (b != 0) {
a = a % b;
swap(a, b);
}
return a;
}
int main() {
int n;
int m;
while (cin >> n >> m) {
cout << gcn(n, m) << " " << n * m / gcn(n, m) << endl;
}
return 0;
}
|
#include <iostream>
#include <utility>
using namespace std;
int gcn(int a, int b) {
if (a < b) {
swap(a, b);
}
while (b != 0) {
a = a % b;
swap(a, b);
}
return a;
}
int main() {
int n;
int m;
while (cin >> n >> m) {
cout << gcn(n, m) << " " << n / gcn(n, m) * m << 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
| 109
| 4
|
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
int a, b, product;
while (std::cin >> a >> b) {
product = a * b;
std::vector<int> v = {a, b};
while (v.at(0) != v.at(1)) {
std::sort(v.begin(), v.end(), std::greater<int>());
v.at(0) = v.at(0) - v.at(1);
}
std::cout << v.at(0) << " " << product / v.at(0) << std::endl;
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
long int a, b, product;
while (std::cin >> a >> b) {
product = a * b;
std::vector<long int> v = {a, b};
while (v.at(0) != v.at(1)) {
std::sort(v.begin(), v.end(), std::greater<long int>());
v.at(0) = v.at(0) - v.at(1);
}
std::cout << v.at(0) << " " << product / v.at(0) << std::endl;
}
return 0;
}
|
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 141, 344, 3, 347, 0, 77, 39, 86, 0, 96], ["+", 141, 346, 3, 347, 0, 77, 39, 86, 0, 96]]
| 1
| 147
| 3
|
#include <iostream>
#include <vector>
int euclid_alg(const int a, const int b) { return a > b ? a % b : b % a; }
int main(void) {
int a, b;
std::vector<int> num;
while (std::cin >> a >> b) {
num.push_back(a);
num.push_back(b);
}
for (int i = 0; i < (int)num.size(); i += 2) {
int pro = num[i] * num[i + 1];
while (num[i] != 0 && num[i + 1] != 0) {
if (num[i] > num[i + 1]) {
num[i] = euclid_alg(num[i], num[i + 1]);
} else {
num[i + 1] = euclid_alg(num[i], num[i + 1]);
}
}
if (num[i] == 0) {
num[i] = num[i + 1];
num[i + 1] = 0;
}
num[i + 1] = pro / num[i];
}
for (int j = 0; j < (int)num.size(); j += 2) {
std::cout << num[j] << " " << num[j + 1] << std::endl;
}
return 0;
}
|
#include <iostream>
#include <vector>
long int euclid_alg(const long int a, const long int b) {
return a > b ? a % b : b % a;
}
int main(void) {
long int a, b;
std::vector<long int> num;
while (std::cin >> a >> b) {
num.push_back(a);
num.push_back(b);
}
for (int i = 0; i < (int)num.size(); i += 2) {
long int pro = num[i] * num[i + 1];
while (num[i] != 0 && num[i + 1] != 0) {
if (num[i] > num[i + 1]) {
num[i] = euclid_alg(num[i], num[i + 1]);
} else {
num[i + 1] = euclid_alg(num[i], num[i + 1]);
}
}
if (num[i] == 0) {
num[i] = num[i + 1];
num[i + 1] = 0;
}
num[i + 1] = pro / num[i];
}
for (int j = 0; j < (int)num.size(); j += 2) {
std::cout << num[j] << " " << num[j + 1] << std::endl;
}
return 0;
}
|
[["+", 36, 36, 0, 30, 0, 14, 39, 86, 0, 96], ["+", 49, 53, 54, 55, 0, 56, 39, 86, 0, 96], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 141, 344, 3, 347, 0, 77, 39, 86, 0, 96], ["+", 0, 7, 8, 9, 0, 43, 39, 86, 0, 96]]
| 1
| 293
| 6
|
#include <iostream>
//最大公約数を求めるプログラム(m >= n)
int calcGcd(int m, int n);
//最小公倍数を求めるプログラム
inline int calcLcm(int m, int n, int gcd);
int main() {
int gcd, lcm, x, y;
while (std::cin >> x >> y) {
if (x > y)
gcd = calcGcd(x, y);
else
gcd = calcGcd(y, x);
lcm = calcLcm(x, y, gcd);
std::cout << gcd << " " << lcm << std::endl;
}
}
int calcGcd(int m, int n) {
if (n == 0)
return m;
else
return calcGcd(n, m % n);
}
inline int calcLcm(int m, int n, int gcd) { return m * n / gcd; }
|
#include <iostream>
//最大公約数を求めるプログラム(m >= n)
int calcGcd(int m, int n);
//最小公倍数を求めるプログラム
inline int calcLcm(int m, int n, int gcd);
int main() {
int gcd, lcm, x, y;
while (std::cin >> x >> y) {
if (x > y)
gcd = calcGcd(x, y);
else
gcd = calcGcd(y, x);
lcm = calcLcm(x, y, gcd);
std::cout << gcd << " " << lcm << std::endl;
}
}
int calcGcd(int m, int n) {
if (n == 0)
return m;
else
return calcGcd(n, m % n);
}
inline int calcLcm(int m, int n, int gcd) { return m / gcd * n; }
|
[["-", 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
| 160
| 17
|
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int main() {
int a, b, c, d;
while (cin >> a >> b) {
c = a;
d = b;
while (1) {
if (a == 0) {
cout << 0 << " " << 0 << endl;
break;
}
if ((max(a, b) % min(a, b)) == 0) {
cout << min(a, b);
break;
} else if (a > b) {
a = a % b;
} else
b = b % a;
}
if (a != 0) {
cout << " " << c * d / min(a, b) << endl;
}
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int main() {
int a, b, c, d;
while (cin >> a >> b) {
c = a;
d = b;
while (1) {
if (a == 0) {
cout << 0 << " " << 0 << endl;
break;
}
if ((max(a, b) % min(a, b)) == 0) {
cout << min(a, b);
break;
} else if (a > b) {
a = a % b;
} else
b = b % a;
}
if (a != 0) {
cout << " " << c / min(a, b) * d << 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
| 158
| 4
|
// B.cpp
#include <iostream>
using namespace std;
int gcd(int, int);
int lcm(int, int);
int main(void) {
int a, b;
cin >> a >> b;
cout << gcd(a, b) << " " << lcm(a, b) << endl;
return 0;
}
int gcd(int a, int b) {
int max, min, res;
res = 1;
if (a > b) {
max = a, min = b;
}
if (a < b) {
max = b, min = a;
}
if (min == 0)
return max;
while (res) {
res = max % min;
max = min;
min = res;
}
return max;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
|
// B.cpp
#include <iostream>
using namespace std;
int gcd(int, int);
int lcm(int, int);
int main(void) {
int a, b;
while (cin >> a >> b) {
cout << gcd(a, b) << " " << lcm(a, b) << endl;
}
return 0;
}
int gcd(int a, int b) {
int max, min, res;
res = 1;
if (a > b) {
max = a, min = b;
}
if (a <= b) {
max = b, min = a;
}
if (min == 0)
return max;
while (res) {
res = max % min;
max = min;
min = res;
}
return max;
}
int lcm(int a, int b) { return a / gcd(a, b) * 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], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
| 1
| 175
| 8
|
#include <cmath>
#include <stdio.h>
using namespace std;
int lcm(int max, int min) {
int multiplier = 1;
while ((max * multiplier) % min != 0) {
multiplier++;
}
return max * multiplier;
}
int gcd(int max, int min) {
int r = max % min;
int x = min;
while (r != 0) {
int tmp = r;
r = x % r;
x = tmp;
}
return x;
}
int main(void) {
int a, b;
while (scanf("%d %d", &a, &b) + 1) {
int min = (a < b) ? a : b;
int max = (a < b) ? b : a;
printf("%d %d\n", lcm(max, min), gcd(max, min));
}
return 0;
}
|
#include <cmath>
#include <stdio.h>
using namespace std;
int lcm(int max, int min) {
int multiplier = 1;
while ((max * multiplier) % min != 0) {
multiplier++;
}
return max * multiplier;
}
int gcd(int max, int min) {
int r = max % min;
int x = min;
while (r != 0) {
int tmp = r;
r = x % r;
x = tmp;
}
return x;
}
int main(void) {
int a, b;
while (scanf("%d %d", &a, &b) + 1) {
int min = (a < b) ? a : b;
int max = (a < b) ? b : a;
printf("%d %d\n", gcd(max, min), lcm(max, min));
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 2, 63, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 2, 63, 22]]
| 1
| 177
| 4
|
#include <stdio.h>
int main(void) {
int a, aa, b, bb, c, s, ss;
while (scanf("%d %d", &a, &b) != EOF) {
aa = a;
bb = b;
if (a < b) {
c = a;
a = b;
b = c;
}
while (1) {
if (a % b == 0) {
break;
} else {
c = a % b;
a = b;
b = c;
}
}
s = b;
ss = aa * bb / b;
printf("%d %d\n", s, ss);
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int a, aa, b, bb, c, s, ss;
while (scanf("%d %d", &a, &b) != EOF) {
aa = a;
bb = b;
if (a < b) {
c = a;
a = b;
b = c;
}
while (1) {
if (a % b == 0) {
break;
} else {
c = a % b;
a = b;
b = c;
}
}
s = b;
ss = aa / b * bb;
printf("%d %d\n", s, ss);
}
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]]
| 1
| 133
| 4
|
#include <iostream>
using namespace std;
int gcd(int a, int b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
int main() {
int a, b;
cin >> a >> b;
int ans1 = gcd(a, b);
cout << ans1 << " " << a / ans1 * 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() {
int a, b;
while (cin >> a >> b) {
int ans1 = gcd(a, b);
cout << ans1 << " " << a / ans1 * 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
| 84
| 6
|
#include <iostream>
using namespace std;
int main() {
int a, b, GCD, LCM, c;
while (cin >> a >> b) {
if (a > b) {
c = b;
} else {
c = a;
}
for (int i = 1; i <= (c / 2 + 1); i++) {
if (b % i == 0 && a % i == 0) {
GCD = i;
}
}
if (b % a == 0 || a % b == 0) {
GCD = c;
}
LCM = a * b / GCD;
cout << GCD << " " << LCM << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int a, b, GCD, LCM, c;
while (cin >> a >> b) {
if (a > b) {
c = b;
} else {
c = a;
}
for (int i = 1; i <= (c / 2 + 1); i++) {
if (b % i == 0 && a % i == 0) {
GCD = i;
}
}
if (b % a == 0 || a % b == 0) {
GCD = c;
}
LCM = a / GCD * b;
cout << GCD << " " << LCM << endl;
}
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]]
| 1
| 137
| 4
|
#include <iostream>
using namespace std;
int main() {
int a, b, m, n, tmp;
while (cin >> a >> b) {
if (a > b) {
m = a;
n = b;
} else {
m = b;
n = a;
}
while (n != 0) {
tmp = n;
n = m % n;
m = tmp;
}
tmp = a * b / m;
cout << m << " " << tmp << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
long long int a, b, m, n, tmp;
while (cin >> a >> b) {
if (a > b) {
m = a;
n = b;
} else {
m = b;
n = a;
}
while (n != 0) {
tmp = n;
n = m % n;
m = tmp;
}
tmp = a * b / m;
cout << m << " " << tmp << endl;
}
return 0;
}
|
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
| 1
| 105
| 2
|
#include <cstdio>
using namespace std;
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a - (a / b) * b);
}
int main() {
int a, b;
int g, l;
int tmp;
if (!(scanf("%d %d", &a, &b) == EOF)) {
g = gcd(a, b);
l = a / g * b;
printf("%d %d", g, l);
}
}
|
#include <cstdio>
using namespace std;
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a - (a / b) * b);
}
int main() {
int a, b;
int g, l;
int tmp;
while (!(scanf("%d %d", &a, &b) == EOF)) {
g = gcd(a, b);
l = a / g * b;
printf("%d %d\n", g, l);
}
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 1
| 111
| 3
|
/*
*AOJ0005 GCD and LCM
**問題
[http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0005&lang=jp]
*/
#include <algorithm>
#include <cmath>
#include <fstream>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
int main() {
// ifstream cin("../test.txt");
int a, b, g;
long long l;
while (cin >> a >> b) {
g = gcd(a, b);
l = a * b / g;
cout << g << " " << l << endl;
}
}
|
#include <algorithm>
#include <cmath>
#include <fstream>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
int main() {
int a, b, g;
long long l;
while (cin >> a >> b) {
g = gcd(a, b);
l = a / g * b / g * g;
cout << g << " " << l << endl;
}
}
|
[["+", 12, 16, 31, 16, 31, 16, 31, 16, 17, 85], ["+", 12, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48]]
| 1
| 106
| 4
|
#include <iostream>
using namespace std;
int main() {
int a, b, gcd, lcm, tmp, r, num_a, num_b;
while (cin >> num_a >> num_b) {
a = num_a, b = num_b;
if (a < b) {
tmp = a;
a = b;
b = tmp;
}
r = a % b;
while (r != 0) {
a = b;
b = r;
r = a % b;
}
gcd = b;
lcm = (num_a * num_b) / gcd;
cout << gcd << " " << lcm << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
long long int a, b, gcd, lcm, tmp, r, num_a, num_b;
while (cin >> num_a >> num_b) {
a = num_a;
b = num_b;
if (a < b) {
tmp = a;
a = b;
b = tmp;
}
r = a % b;
while (r != 0) {
a = b;
b = r;
r = a % b;
}
gcd = b;
lcm = (num_a * num_b) / gcd;
cout << gcd << " " << lcm << endl;
}
return 0;
}
|
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 52, 8, 9, 0, 1, 0, 34, 0, 21], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 124
| 4
|
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
long gcd(int m, int n) {
if ((0 == m) || (0 == n))
return 0;
while (m != n) {
if (m > n)
m = m - n;
else
n = n - m;
}
return m;
}
long lcm(int m, int n) {
if ((0 == m) || (0 == n))
return 0;
return ((m / gcd(m, n)) * n);
}
int main() {
vector<int> v1;
vector<int> v2;
while (cin) {
int a, b;
cin >> a >> b;
v1.push_back(a);
v2.push_back(b);
}
for (int i = 0; i < v1.size(); i++) {
cout << gcd(v1[i], v2[i]) << " " << lcm(v1[i], v2[i]) << endl;
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
long long gcd(int m, int n) {
if ((0 == m) || (0 == n))
return 0;
while (m != n) {
if (m > n)
m = m - n;
else
n = n - m;
}
return m;
}
long long lcm(int m, int n) {
if ((0 == m) || (0 == n))
return 0;
return ((m / gcd(m, n)) * n);
}
int main() {
vector<int> v1;
vector<int> v2;
while (cin) {
int a, b;
cin >> a >> b;
v1.push_back(a);
v2.push_back(b);
}
for (int i = 0; i < v1.size() - 1; i++) {
cout << gcd(v1[i], v2[i]) << " " << lcm(v1[i], v2[i]) << endl;
}
return 0;
}
|
[["+", 36, 36, 0, 30, 0, 14, 39, 86, 0, 96], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
| 1
| 218
| 4
|
//#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, x, n) for (int i = x; i < (int)n; ++i)
#define repi(i, n) for (int i = 0; i <= (int)n; ++i)
#define REPI(i, x, n) for (int i = x; i <= (int)n; ++i)
#define ILP while (true)
#define FOR(i, c) \
for (__typeof((c).begin()) != (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion
// Effective std
#pragma region ESTD
template <typename C, typename T> constexpr int count(C &c, T t) {
return count(ALL(c), t);
}
template <typename C, typename F> constexpr int count_if(C &c, F f) {
return count_if(ALL(c), f);
}
template <typename C, typename T, typename U>
constexpr void replace(C &c, T t, U u) {
replace(ALL(c), t, u);
}
template <typename C, typename F, typename U>
constexpr void replace_if(C &c, F f, U u) {
(ALL(c), f, u);
}
template <typename C> constexpr void sort(C &c) { sort(ALL(c)); }
template <typename C, typename Pred> constexpr void sort(C &c, Pred p) {
sort(ALL(c), p);
}
template <typename C> constexpr void reverse(C &c) { reverse(ALL(c)); }
#pragma endregion
// ?´???°
#pragma region PRIME
bool is_prime(unsigned n) {
switch (n) {
case 0:
case 1:
return false;
case 2:
return true;
}
if (n % 2 == 0)
return false;
for (unsigned i = 3; i * i <= n; i += 2)
if (n % i == 0)
return false;
return true;
}
#pragma endregion
// ??§??????/?°?????????????
#pragma region TRANSFORM
void mutal_tr(string &s) {
for (int i = s.size(); i--;) {
if (islower(s[i]))
s[i] = toupper(s[i]);
else if (isupper(s[i]))
s[i] = tolower(s[i]);
}
}
void to_upper(string &s) {
for (int i = s.size(); i--;)
s[i] = toupper(s[i]);
}
void to_lower(string &s) {
for (int i = s.size(); i--;)
s[i] = tolower(s[i]);
}
#pragma endregion
// ??????
#pragma region SET
template <class T> set<T> intersection(const set<T> &sa, const set<T> &sb) {
set<T> ret;
for (T a : sa)
if (sb.find(a) != sb.end())
ret.insert(a);
return ret;
}
#pragma endregion
// Union Find
#pragma region UF
struct UnionFind {
vector<int> data;
UnionFind(int size) : data(size, -1) {}
bool union_set(int x, int y) {
x = root(x);
y = root(y);
if (x != y) {
if (data[y] < data[x])
swap(x, y);
data[x] += data[y];
data[y] = x;
}
return x != y;
}
bool find_set(int x, int y) { return root(x) == root(y); }
int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
int size(int x) { return -data[root(x)]; }
};
#pragma endregion
// ?????°
#pragma region CONST_VAL
#define PI (2 * acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9 + 7)
#pragma endregion
int gcd(int m, int n) {
if ((0 == m) || (0 == n))
return 0;
while (m != n) {
if (m > n)
m = m - n;
else
n = n - m;
}
return m;
}
int lcm(int m, int n) {
if ((0 == m) || (0 == n))
return 0;
return ((m / gcd(m, n)) * n);
}
int main() {
int a, b;
while (cin >> a >> b) {
printf("%d %d", gcd(a, b), lcm(a, b));
}
return 0;
}
|
//#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, x, n) for (int i = x; i < (int)n; ++i)
#define repi(i, n) for (int i = 0; i <= (int)n; ++i)
#define REPI(i, x, n) for (int i = x; i <= (int)n; ++i)
#define ILP while (true)
#define FOR(i, c) \
for (__typeof((c).begin()) != (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion
// Effective std
#pragma region ESTD
template <typename C, typename T> constexpr int count(C &c, T t) {
return count(ALL(c), t);
}
template <typename C, typename F> constexpr int count_if(C &c, F f) {
return count_if(ALL(c), f);
}
template <typename C, typename T, typename U>
constexpr void replace(C &c, T t, U u) {
replace(ALL(c), t, u);
}
template <typename C, typename F, typename U>
constexpr void replace_if(C &c, F f, U u) {
(ALL(c), f, u);
}
template <typename C> constexpr void sort(C &c) { sort(ALL(c)); }
template <typename C, typename Pred> constexpr void sort(C &c, Pred p) {
sort(ALL(c), p);
}
template <typename C> constexpr void reverse(C &c) { reverse(ALL(c)); }
#pragma endregion
// ?´???°
#pragma region PRIME
bool is_prime(unsigned n) {
switch (n) {
case 0:
case 1:
return false;
case 2:
return true;
}
if (n % 2 == 0)
return false;
for (unsigned i = 3; i * i <= n; i += 2)
if (n % i == 0)
return false;
return true;
}
#pragma endregion
// ??§??????/?°?????????????
#pragma region TRANSFORM
void mutal_tr(string &s) {
for (int i = s.size(); i--;) {
if (islower(s[i]))
s[i] = toupper(s[i]);
else if (isupper(s[i]))
s[i] = tolower(s[i]);
}
}
void to_upper(string &s) {
for (int i = s.size(); i--;)
s[i] = toupper(s[i]);
}
void to_lower(string &s) {
for (int i = s.size(); i--;)
s[i] = tolower(s[i]);
}
#pragma endregion
// ??????
#pragma region SET
template <class T> set<T> intersection(const set<T> &sa, const set<T> &sb) {
set<T> ret;
for (T a : sa)
if (sb.find(a) != sb.end())
ret.insert(a);
return ret;
}
#pragma endregion
// Union Find
#pragma region UF
struct UnionFind {
vector<int> data;
UnionFind(int size) : data(size, -1) {}
bool union_set(int x, int y) {
x = root(x);
y = root(y);
if (x != y) {
if (data[y] < data[x])
swap(x, y);
data[x] += data[y];
data[y] = x;
}
return x != y;
}
bool find_set(int x, int y) { return root(x) == root(y); }
int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
int size(int x) { return -data[root(x)]; }
};
#pragma endregion
// ?????°
#pragma region CONST_VAL
#define PI (2 * acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9 + 7)
#pragma endregion
int gcd(int m, int n) {
if ((0 == m) || (0 == n))
return 0;
while (m != n) {
if (m > n)
m = m - n;
else
n = n - m;
}
return m;
}
int lcm(int m, int n) {
if ((0 == m) || (0 == n))
return 0;
return ((m / gcd(m, n)) * n);
}
int main() {
int a, b;
while (cin >> a >> b) {
printf("%d %d\n", gcd(a, b), lcm(a, b));
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 1
| 1,068
| 1
|
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
int c;
while (b != 0) {
c = a % b;
a = b;
b = c;
}
return (a);
}
int lcm(int a, int b) {
if (a == 0 || b == 0)
return (0);
return ((a / gcd(a, b)) * b);
}
int main() {
int a, b;
cin >> a >> b;
cout << gcd(a, b) << " " << lcm(a, b) << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
int c;
while (b != 0) {
c = a % b;
a = b;
b = c;
}
return (a);
}
int lcm(int a, int b) {
if (a == 0 || b == 0)
return (0);
return ((a / gcd(a, b)) * b);
}
int main() {
int a, b;
while (cin >> a >> b) {
cout << gcd(a, b) << " " << lcm(a, b) << endl;
}
}
|
[["+", 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
| 128
| 6
|
#include <iomanip>
#include <iostream>
using namespace std;
double eucAlg(int a, int b);
int main(int argc, char *argv[]) {
double a, b; //??\??????
double c, d; //??????
cin >> a >> b;
c = eucAlg(a, b);
d = a * b / c;
cout << fixed << setprecision(0) << c << " " << d << endl;
return 0;
}
//??????????????????????????????
double eucAlg(int a, int b) {
double c;
do {
c = a % b;
if (c == 0) {
break;
}
a = b;
b = c;
} while (1);
return b;
}
|
#include <iomanip>
#include <iostream>
using namespace std;
double eucAlg(int a, int b);
int main(int argc, char *argv[]) {
double a, b; //??\??????
double c, d; //??????
while (cin >> a >> b) {
c = eucAlg(a, b);
d = a * b / c;
cout << fixed << setprecision(0) << c << " " << d << endl;
}
return 0;
}
//??????????????????????????????
double eucAlg(int a, int b) {
double c;
do {
c = a % b;
if (c == 0) {
break;
}
a = b;
b = c;
} while (1);
return 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
| 139
| 6
|
#include <iostream>
using namespace std;
int main() {
long long a, b, GCD, LCM, x, a2, b2;
cin >> a >> b;
a2 = a;
b2 = b;
while (a != b) {
if (a > b) {
x = a - b;
a = b;
b = x;
} else if (b > a) {
x = b - a;
b = a;
a = x;
}
}
GCD = a;
LCM = a2 * b2 / a;
cout << GCD << " " << LCM << endl;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
long long a, b, GCD, LCM, x, a2, b2;
while (cin >> a >> b) {
a2 = a;
b2 = b;
while (a != b) {
if (a > b) {
x = a - b;
a = b;
b = x;
} else if (b > a) {
x = b - a;
b = a;
a = x;
}
}
GCD = a;
LCM = a2 * b2 / a;
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
| 122
| 6
|
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
int a, b, m, tmp_a, tmp_b;
while (cin >> a >> b) {
tmp_a = a;
tmp_b = b;
while (tmp_a != 0 && tmp_b != 0) {
if (tmp_a > tmp_b) {
tmp_a = tmp_a % tmp_b;
} else {
tmp_b = tmp_b % tmp_a;
}
}
m = max(tmp_a, tmp_b);
if (m == 0) {
printf("%d %d\n", 0, 0);
} else {
printf("%d %d\n", m, a * b / m);
}
}
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
int a, b, m, tmp_a, tmp_b;
while (cin >> a >> b) {
tmp_a = a;
tmp_b = b;
while (tmp_a != 0 && tmp_b != 0) {
if (tmp_a > tmp_b) {
tmp_a = tmp_a % tmp_b;
} else {
tmp_b = tmp_b % tmp_a;
}
}
m = max(tmp_a, tmp_b);
if (m == 0) {
printf("%d %d\n", 0, 0);
} else {
printf("%d %d\n", m, a / m * b);
}
}
return 0;
}
|
[["-", 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]]
| 1
| 129
| 4
|
#include <iostream>
using namespace std;
int get_gcd(int a, int b) {
if (a % b == 0)
return b;
return get_gcd(b, a % b);
}
int main() {
int a, b;
while (cin >> a >> b) {
if (a < b) {
int tmp = a;
a = b;
b = tmp;
}
int gcd = get_gcd(a, b);
int lcm = (a * b) / gcd;
cout << gcd << " " << lcm << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int get_gcd(int a, int b) {
if (a % b == 0)
return b;
return get_gcd(b, a % b);
}
int main() {
int a, b;
while (cin >> a >> b) {
if (a < b) {
int tmp = a;
a = b;
b = tmp;
}
int gcd = get_gcd(a, b);
int lcm = a / gcd * b;
cout << gcd << " " << lcm << endl;
}
return 0;
}
|
[["-", 0, 43, 49, 50, 51, 16, 31, 23, 0, 24], ["-", 49, 50, 51, 16, 31, 23, 0, 16, 17, 48], ["-", 49, 50, 51, 16, 31, 23, 0, 16, 12, 22], ["-", 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
| 116
| 6
|
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
long long int find_GCD(long long int a, long long int b) {
long long int max = 0;
for (int i = min(a, b); i > 0; i--) {
if (a % i == 0 && b % i == 0) {
max = i;
break;
}
}
return max;
}
long long int find_LCM(long long int a, long long int b) {
long long int LCM;
for (int i = max(a, b); i <= a * b; i += max(a, b)) {
if (i % a == 0 && i % b == 0) {
break;
}
}
}
int main() {
long long int a, b;
while (cin >> a >> b) {
// cout << a << " " << b <<endl;
// int GCD = find_GCD(a, b);
// cout << GCD << endl;
// cout << find_GCD(a, b) << endl;
// long long int GCD = find_GCD(a, b);
// long long int LCM = a*b/GCD;
long long int GCD;
long long int LCM;
LCM = find_LCM(a, b);
GCD = a * b / LCM;
cout << GCD << " " << LCM << endl;
}
}
|
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
long long int find_GCD(long long int a, long long int b) {
long long int max = 0;
for (int i = min(a, b); i > 0; i--) {
if (a % i == 0 && b % i == 0) {
max = i;
break;
}
}
return max;
}
long long int find_LCM(long long int a, long long int b) {
long long int LCM;
for (int i = max(a, b); i <= a * b; i += max(a, b)) {
if (i % a == 0 && i % b == 0) {
return i;
}
}
}
int main() {
long long int a, b;
while (cin >> a >> b) {
// cout << a << " " << b <<endl;
// int GCD = find_GCD(a, b);
// cout << GCD << endl;
// cout << find_GCD(a, b) << endl;
// long long int GCD = find_GCD(a, b);
// long long int LCM = a*b/GCD;
long long int GCD;
long long int LCM;
LCM = find_LCM(a, b);
GCD = a * b / LCM;
cout << GCD << " " << LCM << endl;
}
}
|
[["-", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 22]]
| 1
| 217
| 3
|
#include <iostream>
using namespace std;
long long int gcd(long long int m, long long int n) {
if (n == 0)
return m;
return gcd(n, m % n);
}
int main() {
long long int a, b;
while (cin >> a >> b)
cout << gcd(a, b) << a * b / gcd(a, b) << endl;
return 0;
}
|
#include <iostream>
using namespace std;
long long int gcd(long long int m, long long int n) {
if (n == 0)
return m;
return gcd(n, m % n);
}
int main() {
long long int a, b;
while (cin >> a >> b)
cout << gcd(a, b) << " " << a * b / gcd(a, b) << endl;
return 0;
}
|
[["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 52, 8, 1, 0, 16, 31, 16, 17, 151]]
| 1
| 88
| 4
|
#include <cstdio>
#include <iostream>
using namespace std;
int a, b;
int gcd, lcm;
void GCD() {
int big, small;
big = a;
small = b;
while (big) {
if (small > big)
swap(big, small);
big = big % small;
}
gcd = small;
}
void LCM() { lcm = a * b / gcd; }
int main() {
while (cin >> a >> b) {
GCD();
LCM();
cout << gcd << " " << lcm << endl;
}
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
long long a, b;
long long int gcd, lcm;
void GCD() {
int big, small;
big = a;
small = b;
while (big) {
if (small > big)
swap(big, small);
big = big % small;
}
gcd = small;
}
void LCM() { lcm = a * b / gcd; }
int main() {
while (cin >> a >> b) {
GCD();
LCM();
cout << gcd << " " << lcm << endl;
}
return 0;
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96]]
| 1
| 119
| 10
|
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
int a, b;
while (cin >> a >> b) {
cout << a * b / (a / __gcd(a, b) * b) << " " << a / __gcd(a, b) * b << endl;
}
}
|
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
long long int a, b;
while (cin >> a >> b) {
cout << a * b / (a / __gcd(a, b) * b) << " " << a / __gcd(a, b) * b << endl;
}
}
|
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
| 1
| 65
| 12
|
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
int a, b;
while (cin >> a >> b) {
cout << a * b / (a / __gcd(a, b) * b) << " " << a / __gcd(a, b) * b << endl;
}
}
|
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
long int a, b;
while (cin >> a >> b) {
/*cout << __gcd(a, b) << " " << a * b / gcd(a, b) << endl;*/
cout << a * b / (a / __gcd(a, b) * b) << " " << a / __gcd(a, b) * b << endl;
}
}
|
[["+", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["+", 36, 36, 36, 36, 0, 30, 0, 135, 0, 138], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
| 1
| 65
| 12
|
#include <algorithm>
#include <iostream>
using namespace std;
int main(void) {
int x, y, g, l, t;
while (cin >> x >> y) {
if (x < y)
swap(x, y);
g = __gcd(x, y);
l = x * y / g;
cout << g << " " << l << endl;
}
return 0;
}
|
#include <algorithm>
#include <iostream>
using namespace std;
int main(void) {
long long int x, y, g, l, t;
while (cin >> x >> y) {
if (x < y)
swap(x, y);
g = __gcd(x, y);
l = x * y / g;
cout << g << " " << l << endl;
}
return 0;
}
|
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
| 1
| 81
| 2
|
#include <algorithm>
#include <iostream>
using namespace std;
int gcd(int m, int n) {
if (n == 0)
return m;
return gcd(n, m % n);
}
int lcm(int m, int n) { return ((m * n) / gcd(m, n)); }
int main() {
int m, n;
while (cin >> m >> n) {
cout << gcd(m, n) << " " << lcm(m, n) << endl;
}
return 0;
}
|
#include <algorithm>
#include <iostream>
using namespace std;
int gcd(int m, int n) {
if (n == 0)
return m;
return gcd(n, m % n);
}
int lcm(int m, int n) { return ((m / gcd(m, n)) * n); }
int main() {
int m, n;
while (cin >> m >> n) {
cout << gcd(m, n) << " " << lcm(m, n) << endl;
}
return 0;
}
|
[["-", 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
| 111
| 6
|
#include <cmath>
#include <iostream>
using namespace std;
long long a, b;
long long gcd(long long x, long long y) {
if (b == 0)
return x;
else
return gcd(y, x % y);
}
long long lcm(long long x, long long y) { return (x * y) / gcd(x, y); }
int main() {
while (cin >> a >> b) {
cout << gcd(a, b) << " " << lcm(a, b) << endl;
}
return 0;
}
|
#include <cmath>
#include <iostream>
using namespace std;
long long a, b;
long long gcd(long long x, long long y) {
if (y == 0)
return x;
else
return gcd(y, x % y);
}
long long lcm(long long x, long long y) { return (x * y) / gcd(x, y); }
int main() {
while (cin >> a >> b) {
cout << gcd(a, b) << " " << lcm(a, b) << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
| 1
| 117
| 2
|
#include <iostream>
using namespace std;
int main() {
int a, b, r, g, l;
while (cin >> a >> b) {
l = a * b;
if (a < b)
swap(a, b);
do {
r = a % b;
a = b;
b = r;
} while (r);
g = a;
l /= g;
cout << g << ' ' << l << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
long long a, b, r, g, l;
while (cin >> a >> b) {
l = a * b;
if (a < b)
swap(a, b);
do {
r = a % b;
a = b;
b = r;
} while (r);
g = a;
l /= g;
cout << g << ' ' << l << endl;
}
return 0;
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
| 1
| 97
| 3
|
#include <iostream>
using namespace std;
int main() {
int a, b, big, small, r;
while (1) {
cin >> a >> b;
if (cin.eof()) {
break;
}
if (a > b) {
big = a;
small = b;
} else {
big = b;
small = a;
}
r = big % small;
while (r != 0) {
big = small;
small = r;
r = big % small;
}
}
cout << small << ' ' << (a / small) * (b / small) * small << endl;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int a, b, big, small, r;
while (1) {
cin >> a >> b;
if (cin.eof()) {
break;
}
if (a > b) {
big = a;
small = b;
} else {
big = b;
small = a;
}
r = big % small;
while (r != 0) {
big = small;
small = r;
r = big % small;
}
cout << small << ' ' << (a / small) * (b / small) * small << endl;
}
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 129
| 2
|
#include <iostream>
using namespace std;
int gcd(int x, int y) {
if (x % y == 0)
return y;
else {
int z = x % y;
return gcd(y, z);
}
}
int main() {
int a, b;
int g;
long int l;
while (cin >> a >> b) {
if (a > b)
g = gcd(a, b);
else if (a < b)
g = gcd(b, a);
else
g = a;
l = a * b / g;
cout << g << " " << l << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int gcd(int x, int y) {
if (x % y == 0)
return y;
else {
int z = x % y;
return gcd(y, z);
}
}
int main() {
int a, b;
int g;
long int l;
while (cin >> a >> b) {
if (a > b)
g = gcd(a, b);
else if (a < b)
g = gcd(b, a);
else
g = a;
l = (long int)a * b / g;
cout << g << " " << l << endl;
}
return 0;
}
|
[["+", 0, 11, 12, 16, 31, 16, 31, 74, 0, 24], ["+", 31, 16, 31, 74, 39, 77, 39, 86, 0, 96], ["+", 31, 16, 31, 74, 39, 77, 39, 86, 39, 40], ["+", 0, 11, 12, 16, 31, 16, 31, 74, 0, 25]]
| 1
| 133
| 4
|
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
int main() {
vector<int> a(2);
while (cin >> a[0] >> a[1]) {
sort(a.begin(), a.end());
int b = gcd(a[1], a[0]);
cout << b << " " << a[1] * a[0] / b << endl;
}
}
|
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define int long long
using namespace std;
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
signed main() {
vector<int> a(2);
while (cin >> a[0] >> a[1]) {
sort(a.begin(), a.end());
int b = gcd(a[1], a[0]);
cout << b << " " << a[1] * a[0] / b << endl;
}
}
|
[["+", 36, 36, 36, 36, 0, 30, 0, 58, 0, 148], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 141, 22], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 0, 30, 0, 14, 39, 86, 0, 156]]
| 1
| 126
| 5
|
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define RREP(i, n) for (int(i) = (int)(n)-1; i >= 0; i--)
#define iREP(i, Itr) for (auto(i) = (Itr).begin(); (i) != (Itr).end(); (i)++)
#define REMOVE(Itr, n) \
(Itr).erase(remove((Itr).begin(), (Itr).end(), n), (Itr).end())
#define PB_VEC(Itr1, Itr2) \
(Itr1).insert((Itr1).end(), (Itr2).begin(), (Itr2).end())
#define UNIQUE(Itr) \
sort((Itr).begin(), (Itr).end()); \
(Itr).erase(unique((Itr).begin(), (Itr).end()), (Itr).end())
#define LBOUND(Itr, val) lower_bound((Itr).begin(), (Itr).end(), (val))
#define UBOUND(Itr, val) upper_bound((Itr).begin(), (Itr).end(), (val))
typedef long long ll;
long long gcd(long long a, long long b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
int main() {
ll a, b;
while (cin >> a >> b) {
cout << gcd(a, b) << lcm(a, b) << endl;
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define RREP(i, n) for (int(i) = (int)(n)-1; i >= 0; i--)
#define iREP(i, Itr) for (auto(i) = (Itr).begin(); (i) != (Itr).end(); (i)++)
#define REMOVE(Itr, n) \
(Itr).erase(remove((Itr).begin(), (Itr).end(), n), (Itr).end())
#define PB_VEC(Itr1, Itr2) \
(Itr1).insert((Itr1).end(), (Itr2).begin(), (Itr2).end())
#define UNIQUE(Itr) \
sort((Itr).begin(), (Itr).end()); \
(Itr).erase(unique((Itr).begin(), (Itr).end()), (Itr).end())
#define LBOUND(Itr, val) lower_bound((Itr).begin(), (Itr).end(), (val))
#define UBOUND(Itr, val) upper_bound((Itr).begin(), (Itr).end(), (val))
typedef long long ll;
long long gcd(long long a, long long b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
int main() {
ll a, b;
while (cin >> a >> b) {
cout << gcd(a, b) << " " << lcm(a, b) << 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
| 201
| 4
|
#include <iostream>
using namespace std;
int gcd(int a, int b) {
if (b == 0)
return a;
else if (a < b)
return gcd(b, a);
else
return gcd(b, a % b);
}
int main() {
int a, b;
while ((cin >> a) && (cin >> b)) {
int g = gcd(a, b);
int l = a * b / g;
cout << g << " " << l << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int gcd(int a, int b) {
if (b == 0)
return a;
else if (a < b)
return gcd(b, a);
else
return gcd(b, a % b);
}
int main() {
int a, b;
while ((cin >> a) && (cin >> b)) {
int g = gcd(a, b);
int l = (a / g) * b;
cout << g << " " << l << endl;
}
return 0;
}
|
[["+", 0, 43, 49, 50, 51, 16, 31, 23, 0, 24], ["-", 0, 43, 49, 50, 51, 16, 31, 16, 17, 48], ["-", 0, 43, 49, 50, 51, 16, 31, 16, 12, 22], ["+", 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
| 113
| 6
|
#include <iostream>
using namespace std;
int main() {
long long a, b;
long long min, max;
while (cin >> a >> b) {
if (b > a) {
long long dum = a;
a = b;
b = dum;
}
// cout << "a=" << a << "b=" << b << endl;
//?????§??¬?´???°????±???????
//???????????????????????????
long long new_a = a, new_b = b;
long long r;
while (1) {
r = new_a % new_b;
if (r == 0) {
max = b;
break;
} else {
new_a = new_b;
new_b = r;
continue;
}
}
//????°???¬?????°????±???????
// 2,000,000,000?????§?????????
long long i = 1, j = 1;
while (a * i < 2000000000 && b * j < 2000000000) {
// cout << "ai=" << a*i << " bj=" << b*j << endl;
if (a * i == b * j) {
min = a * i;
break;
} else if (a * i < b * j) {
i++;
} else if (a * i > b * j) {
j++;
}
}
cout << max << " " << min << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
long long a, b;
long long min, max;
while (cin >> a >> b) {
if (b > a) {
long long dum = a;
a = b;
b = dum;
}
// cout << "a=" << a << "b=" << b << endl;
//?????§??¬?´???°????±???????
//???????????????????????????
long long new_a = a, new_b = b;
long long r;
while (1) {
r = new_a % new_b;
if (r == 0) {
max = new_b;
break;
} else {
new_a = new_b;
new_b = r;
continue;
}
}
//????°???¬?????°????±???????
// 2,000,000,000?????§?????????
long long i = 1, j = 1;
while (a * i < 2000000000 && b * j < 2000000000) {
// cout << "ai=" << a*i << " bj=" << b*j << endl;
if (a * i == b * j) {
min = a * i;
break;
} else if (a * i < b * j) {
i++;
} else if (a * i > b * j) {
j++;
}
}
cout << max << " " << min << endl;
}
return 0;
}
|
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]]
| 1
| 208
| 2
|
#include <stdio.h>
#include <string.h>
int GCD(int x, int y) {
if (y == 0)
return x;
return GCD(y, x % y);
}
int LCM(int x, int y) {
int i;
for (i = 1; i <= y; i++) {
if ((x % i) % y == 0)
return x * i;
}
return x * y;
}
int main(void) {
int a, b, k;
while (scanf("%d %d", &a, &b) != EOF) {
if (a < b) {
k = b;
b = a;
a = k;
}
printf("%d %d\n", GCD(a, b), LCM(a, b));
}
}
|
#include <stdio.h>
#include <string.h>
int GCD(int x, int y) {
if (y == 0)
return x;
return GCD(y, x % y);
}
int LCM(int x, int y) {
int i;
for (i = 1; i <= y; i++) {
if ((x * i) % y == 0)
return x * i;
}
return x * y;
}
int main(void) {
int a, b, k;
while (scanf("%d %d", &a, &b) != EOF) {
if (a < b) {
k = b;
b = a;
a = k;
}
printf("%d %d\n", GCD(a, b), LCM(a, b));
}
}
|
[["-", 51, 16, 31, 16, 31, 23, 0, 16, 17, 109], ["+", 51, 16, 31, 16, 31, 23, 0, 16, 17, 48]]
| 1
| 160
| 2
|
#include <iostream>
using namespace std;
int main() {
int a, b, ta, tb, tc;
while (cin >> a >> b) {
ta = a;
tb = b;
while (1) {
if (ta < tb) {
tc = ta;
ta = tb;
tb = tc;
}
tc = ta % tb;
if (tc == 0)
break;
ta = tb;
tb = tc;
}
cout << tb << " " << a * b / tb << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int a, b, ta, tb, tc;
while (cin >> a >> b) {
ta = a;
tb = b;
while (1) {
if (ta < tb) {
tc = ta;
ta = tb;
tb = tc;
}
tc = ta % tb;
if (tc == 0)
break;
ta = tb;
tb = tc;
}
cout << tb << " " << a / tb * 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
| 108
| 4
|
#include <iostream>
using namespace std;
int getGCD(int a, int b) { return b ? getGCD(b, a % b) : a; }
int main() {
int a, b, gcd;
while (cin >> a >> b) {
gcd = getGCD(a, b);
cout << gcd << " " << a * b / gcd << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int getGCD(int a, int b) { return b ? getGCD(b, a % b) : a; }
int main() {
int a, b, gcd;
while (cin >> a >> b) {
gcd = getGCD(a, b);
cout << gcd << " " << (long long)a * b / gcd << endl;
}
return 0;
}
|
[["+", 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
| 82
| 4
|
#include <iostream>
using namespace std;
int gcd(int a, int b);
int lcm(int a, int b);
int main() {
int a, b, c, d;
while (cin >> a >> b) {
c = gcd(a, b);
d = lcm(a, b);
cout << a << " " << b << endl;
}
return 0;
}
int gcd(int a, int b) {
int d, e, f;
if (a >= b) {
d = a;
e = b;
} else {
d = b;
e = a;
}
f = e;
while (1) {
if (d % f == 0)
return f;
f = d % e;
d = e;
e = f;
}
}
int lcm(int a, int b) {
int c = gcd(a, b);
int d;
d = a;
d /= c;
d *= b;
return d;
}
|
#include <iostream>
using namespace std;
int gcd(int a, int b);
int lcm(int a, int b);
int main() {
int a, b, c, d;
while (cin >> a >> b) {
c = gcd(a, b);
d = lcm(a, b);
cout << c << " " << d << endl;
}
return 0;
}
int gcd(int a, int b) {
int d, e, f;
if (a >= b) {
d = a;
e = b;
} else {
d = b;
e = a;
}
f = e;
while (1) {
if (d % f == 0)
return f;
f = d % e;
d = e;
e = f;
}
}
int lcm(int a, int b) {
int c = gcd(a, b);
int d;
d = a;
d /= c;
d *= b;
return d;
}
|
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
| 1
| 203
| 4
|
//
// main.c
// c
//
// Created by ????????? on 2016/12/10.
// Copyright ?? 2016??´ ?????????. All rights reserved.
//
#include <stdio.h>
int main() {
int a, b, r, lcm, x, y;
while (scanf("%d %d", &a, &b) != EOF) {
x = a;
y = b;
for (;;) {
r = x % y;
if (r == 0)
break;
x = y;
y = r;
}
lcm = a * b / y;
printf("%d %d\n", y, lcm);
}
return 0;
}
|
//
// main.c
// c
//
// Created by ????????? on 2016/12/10.
// Copyright ?? 2016??´ ?????????. All rights reserved.
//
#include <stdio.h>
int main() {
long long a, b, r, lcm, x, y;
while (scanf("%lld %lld", &a, &b) != EOF) {
x = a;
y = b;
for (;;) {
r = x % y;
if (r == 0)
break;
x = y;
y = r;
}
lcm = a * b / y;
printf("%lld %lld\n", y, lcm);
}
return 0;
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 51, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 51, 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]]
| 1
| 107
| 7
|
#include <iomanip>
#include <iostream>
using namespace std;
int GCD(int a, int b) {
if (b > 0) {
return GCD(b, a % b);
} else {
return a;
}
}
int LCM(int a, int b) { return a * b / GCD(a, b); }
int main(int argc, char **argv) {
int a, b;
while (cin >> a >> b)
cout << GCD(a, b) << " " << LCM(a, b) << endl;
return 0;
}
|
#include <iomanip>
#include <iostream>
using namespace std;
int GCD(int a, int b) {
if (b > 0) {
return GCD(b, a % b);
} else {
return a;
}
}
int LCM(int a, int b) { return a / GCD(a, b) * b; }
int main(int argc, char **argv) {
int a, b;
while (cin >> a >> b)
cout << GCD(a, b) << " " << LCM(a, b) << endl;
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
| 117
| 4
|
#include <bits/stdc++.h>
using namespace std;
long gcd(long a, long b) { return a % b ? b : gcd(b, a % b); }
void solve(long a, long b) {
int c = gcd(a, b);
cout << c << " " << a / c * b << endl;
}
int main() {
long a, b;
while (cin >> a >> b)
solve(a, b);
}
|
#include <bits/stdc++.h>
using namespace std;
long gcd(long a, long b) { return a % b ? gcd(b, a % b) : b; }
void solve(long a, long b) {
int c = gcd(a, b);
cout << c << " " << a / c * b << endl;
}
int main() {
long a, b;
while (cin >> a >> b)
solve(a, b);
}
|
[["-", 0, 14, 8, 9, 0, 37, 0, 41, 64, 22], ["-", 0, 14, 8, 9, 0, 37, 0, 41, 0, 102], ["+", 0, 14, 8, 9, 0, 37, 0, 41, 0, 102], ["+", 0, 14, 8, 9, 0, 37, 0, 41, 75, 22]]
| 1
| 96
| 4
|
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
int gcd, lcm, a, b;
while (cin >> a >> b) {
int ac, bc;
ac = a;
bc = b;
if (bc > ac)
swap(ac, bc);
while (ac % bc != 0) {
ac %= bc;
if (bc > ac)
swap(ac, bc);
}
gcd = bc;
lcm = a * b / gcd;
cout << gcd << " " << lcm << endl;
}
return 0;
}
|
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
int gcd, lcm, a, b;
while (cin >> a >> b) {
int ac, bc;
ac = a;
bc = b;
if (bc > ac)
swap(ac, bc);
while (ac % bc != 0) {
ac %= bc;
if (bc > ac)
swap(ac, bc);
}
gcd = bc;
lcm = a / gcd * b;
cout << gcd << " " << lcm << endl;
}
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]]
| 1
| 113
| 4
|
// AOJ0005
#include <iostream>
using namespace std;
int gcd(int n, int m) {
if (m == 0)
return n;
gcd(m, n % m);
}
int main() {
int n, m;
while (cin >> n >> m) {
cout << gcd(n, m) << " " << n * m / gcd(n, m) << endl;
}
return 0;
}
|
// AOJ0005
#include <iostream>
using namespace std;
long long gcd(int n, int m) {
if (m == 0)
return n;
gcd(m, n % m);
}
int main() {
long long n, m;
while (cin >> n >> m) {
cout << gcd(n, m) << " " << n * m / gcd(n, m) << endl;
}
return 0;
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 0, 30, 0, 14, 39, 86, 0, 96], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
| 1
| 86
| 6
|
#include <iostream>
using namespace std;
int gcd(int x, int y);
int main() {
while (true) {
int a, b;
cin >> a >> b;
if (cin.eof())
break;
int c = gcd(a, b);
cout << ' ' << a / c * b << endl;
}
return 0;
}
int gcd(int x, int y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
|
#include <iostream>
using namespace std;
int gcd(int x, int y);
int main() {
while (true) {
int a, b;
cin >> a >> b;
if (cin.eof())
break;
int c = gcd(a, b);
cout << c << ' ' << a / c * b << endl;
}
return 0;
}
int gcd(int x, int y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
|
[["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 1, 0, 16, 31, 16, 31, 16, 17, 151]]
| 1
| 106
| 2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.