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, LC...
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, LC...
[["-", 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))) { ...
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))) { ...
[["-", 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,...
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...
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, ...
[["-", 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(); in...
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(); in...
[["-", 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); ...
/* 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); ...
[["-", 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...
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 = num...
[["-", 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, i...
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, i...
[["-", 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,...
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,...
[["-", 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; ...
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; ...
[["-", 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...
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, lon...
[["-", 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()...
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()...
[["-", 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); /...
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); /...
[["-", 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) + " ...
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) + " ...
[["-", 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...
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 l...
[["-", 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;...
#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...
[["+", 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...
#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...
[["-", 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); } ret...
#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;...
[["+", 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); } retu...
#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); } retu...
[["-", 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 (...
#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 (...
[["-", 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; } } ...
#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; } } ...
[["+", 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) { tmp...
#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) { tmp...
[["-", 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...
#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...
[["-", 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 { ...
#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; ...
[["+", 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" <...
#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...
[["+", 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); ...
[["+", 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 %...
#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; ...
[["-", 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); } ...
#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); }...
[["+", 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; } i...
#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 l...
[["-", 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
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 m...
#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 m...
[["+", 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::...
#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); ...
[["+", 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] * ...
#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...
[["+", 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::c...
#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::c...
[["-", 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) { ...
#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) { ...
[["-", 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) { ...
// 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; } ...
[["+", 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,...
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; ...
#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; ...
[["-", 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; }...
#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; }...
[["-", 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) ...
#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) ...
[["-", 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 << end...
#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 << " " << ...
[["+", 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 gc...
#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); ...
[["+", 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...
#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; ...
[["+", 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 ...
#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;...
[["+", 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> #...
//#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> #...
[["+", 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) <<...
#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 << g...
[["+", 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; } //???????...
#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; } ret...
[["+", 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; ...
#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; } ...
[["+", 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 ...
#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 ...
[["-", 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; co...
#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...
[["-", 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(l...
#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(l...
[["-", 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...
#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() { whil...
[["-", 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) << " ...
#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) << " ...
[["-", 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; ...
#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; ...
[["-", 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 ...
#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 ...
[["+", 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 << " ...
#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...
[["+", 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 ...
#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 ...
[["+", 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; } ...
#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; }...
[["+", 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; //?????§??¬?´???°????±??????? //??????????????????????????? ...
#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; //?????§??¬?´???°????±??????? //??????????????????????????? ...
[["-", 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...
#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...
[["-", 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; } ...
#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; } ...
[["-", 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; ...
#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; ...
[["-", 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 =...
// // 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...
[["-", 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, ...
#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, ...
[["-", 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 *...
#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 /...
[["-", 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