Submission #19554420


Source Code Expand

Copy
import java.util.Collections;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var x = sc.nextInt();
		var list = IntStream.range(0, n).map(i -> sc.nextInt()).boxed().collect(Collectors.toList());
		list.add(x);
		sc.close();
		Collections.sort(list);

		var a = list.get(0);
		var result = 0;
		for (var i = 1; i < list.size(); i++) {
			if (i == 1) {
				result = list.get(i) - a;
			} else {
				result = gcd(result, list.get(i) - a);
			}
		}
		System.out.println(result);
	}

	public static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}
}

Submission Info

Submission Time
Task C - Skip
User tosca2020
Language Java (OpenJDK 11.0.6)
Score 300
Code Size 765 Byte
Status AC
Exec Time 556 ms
Memory 61824 KB

Judge Result

Set Name All Sample
Score / Max Score 300 / 300 0 / 0
Status
AC × 22
AC × 3
Set Name Test Cases
All hand_1, large_1, large_2, large_3, large_4, large_5, large_6, large_7, large_8, max_1, max_2, max_3, min_1, min_2, sample_01, sample_02, sample_03, small_1, small_2, small_3, small_4, small_5
Sample sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
hand_1 AC 119 ms 36216 KB
large_1 AC 273 ms 52944 KB
large_2 AC 293 ms 56428 KB
large_3 AC 280 ms 55876 KB
large_4 AC 115 ms 36532 KB
large_5 AC 123 ms 36604 KB
large_6 AC 118 ms 36464 KB
large_7 AC 115 ms 36180 KB
large_8 AC 113 ms 36284 KB
max_1 AC 545 ms 60820 KB
max_2 AC 541 ms 61824 KB
max_3 AC 556 ms 61024 KB
min_1 AC 114 ms 36132 KB
min_2 AC 115 ms 36140 KB
sample_01 AC 108 ms 36168 KB
sample_02 AC 110 ms 36172 KB
sample_03 AC 110 ms 36168 KB
small_1 AC 117 ms 36500 KB
small_2 AC 119 ms 36232 KB
small_3 AC 113 ms 36364 KB
small_4 AC 118 ms 36584 KB
small_5 AC 110 ms 36184 KB