-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path691B.cpp
More file actions
50 lines (50 loc) · 975 Bytes
/
691B.cpp
File metadata and controls
50 lines (50 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
// int main()
// {
// int n;
// scanf("%d", &n);
// if(n==1){
// printf("4\n");
// }
// else if(n%2==1){
// int a = (n+3)/2;
// int b = (n/2)+1;
// int ans = 2*a*b;
// printf("%d\n",ans);
// }
// else
// {
// int ans = n+1-(n/2);
// ans *= ans;
// printf("%d\n",ans);
// }
// }
int main()
{
int n, m;
scanf("%d %d", &n, &m);
ll arr[n], arr2[m];
for (int i = 0; i < n; i++)
{
scanf("%lld", &arr[i]);
}
sort(arr, arr + n);
ll k = arr[0];
ll ans = 0;
for (int i = 0; i < n - 1; i++)
{
ans = __gcd(ans, arr[i + 1] - arr[i]);
}
// printf("%lld\n", ans);
for (int i = 0; i < m; i++)
{
scanf("%lld", &arr2[i]);
}
for (int i = 0; i < m; i++)
{
printf("%lld ", __gcd(arr2[i]+k,ans));
}
printf("\n");
}