#include<iostream> #include<cstring> #include<algorithm> using namespace std; const int N=5e4; int b[N+2], pm[N+2],tot=0; void init(){ b[1]=1; for(int i=2;i<=N;i++){ if(b[i]) continue; pm[++tot]= i; for(int j=2;j*i<=N;j++) b[j*i]=1; } } int chk(int a,int b){ if(a==0) return 0 ; int num = a*a+ b*b*2; for(int i=1;i<=tot && pm[i]<num;i++) if(num%pm[i]==0) return 0; return 1; } signed main(){ init() ; int ts; cin>>ts; while (ts--) { int a, b; cin>>a>>b; printf("%s\n",chk(a,b)?"Yes":"No"); } }
标签:Prime,int,ts,Gauss,UVA,include,1415 From: https://www.cnblogs.com/towboa/p/17347286.html