赞
踩
Codeforces Round #698 (Div. 2) 全文见:https://blog.csdn.net/qq_43461168/article/details/113405897
思路参考:https://www.cnblogs.com/HotPants/p/14344386.html

#include <iostream> #include <bits/stdc++.h> #include <unordered_map> #define int long long #define mk make_pair #define gcd __gcd using namespace std; const double eps = 1e-10; const int mod = 1e9+7; const int N = 3e6+7; int n,m,k,t = 1,cas = 1; int a[N],b[N]; signed main(){ cin>>t; while(t--){ cin>>n>>m; for(int i = 0 ; i < n ; i ++) cin>>a[i]; int g = a[1]-a[0]; for(int i = 1 ; i < n ; i ++) g = gcd(a[i]-a[i-1],g); puts((m-a[0]) % g == 0 ? "YES" :"NO"); } return 0; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。