You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
700 B
C++

#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 50;
ll x[N], p[N];
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
int main()
{
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++)
scanf("%lld", x + i);
for (int i = 0; i < m; i++)
scanf("%lld", p + i);
ll _g = x[1] - x[0];
for (int i = 1; i < n; i++)
_g = gcd(_g, x[i] - x[i - 1]);
for (int i = 0; i < m; i++)
if (_g % p[i] == 0)
printf("YES\n%lld %d\n", x[0], i + 1), exit(0);
puts("NO");
return 0;
}