其他分享
首页 > 其他分享> > CF1477A Nezzar and Board

CF1477A Nezzar and Board

作者:互联网

CF1477A Nezzar and Board

题意:


样例输入:
6 
2 1
1 2 
3 0
2 3 7
2 -1
31415926 27182818
2 1000000000000000000
1 1000000000000000000
2 -1000000000000000000
-1000000000000000000 123
6 80
-5 -20 13 -14 -2 -11
样例输出:
YES
YES
NO
YES
YES
NO

sol:

如果 \(x_1\) != 0 ,将\(x_1,x_2,x_3....x_n\) 减去\(x_1\) 即可

code:


const int maxn = 2e5 + 10;
ll a[maxn];
int n,m;
void solve() {
	ll k;
	cin >> n >> k;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	ll d = 0;
	for(int i = 1; i < n; i++) {
		d = __gcd(d,abs(a[i]-a[n]));
	}
	if((k-a[n]) % d == 0) cout << "YES" << "\n";
	else cout << "NO" << "\n";

}

标签:Nezzar,gcd,int,1000000000000000000,黑板,CF1477A,Board,YES,ll
来源: https://www.cnblogs.com/ztns/p/14529321.html