# ShanLunjiaJian的blog

### CF1477A Nezzar and Board 题解

posted on 2021-01-29 01:30:44 | under 题解 |

#include<stdio.h>
#include<vector>
#include<map>
using std::vector;
using std::map;

struct Node
{
int a,b,c;
inline bool operator < (Node x) const
{
return a==x.a?b==x.b?c<x.c:b<x.b:a<x.a;
}
};

Node operator + (Node x,Node y)
{
return {x.a*2-y.a,x.b*2-y.b,x.c*2-y.c};
}

vector<Node> v;
map<Node,bool> mp;

int main()
{
v.push_back({0,1,0}),v.push_back({1,0,0}),v.push_back({0,0,1});
int T=2;
while(T--)
{
int t=v.size();
for(int i=0;i<t;i++)
for(int j=0;j<t;j++)
if(!mp[v[i]+v[j]]) v.push_back(v[i]+v[j]),mp[v[i]+v[j]]=1;
}
for(int i=0;i<v.size();i++)
printf("%d %d %d\n",v[i].a,v[i].b,v[i].c);
return 0;
}

#include<stdio.h>

int n;
long long k,a,b,g;

inline long long gcd(long long a,long long b)
{
if(!b) return a;
return gcd(b,a%b);
}

inline long long abs(long long x){ return x<0?-x:x; }

int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%d%I64d%I64d",&n,&k,&a);
g=0;
for(int i=2;i<=n;i++)
scanf("%I64d",&b),g=gcd(g,abs(b-a));
printf((k-a)%g==0?"YES\n":"NO\n");
}
return 0;
}