bitset [HZOI 2016]动物城的鸳鸯蛋传说

 传送门

         神奇的bitset()

 我太弱才学会bitset 。用来制造一个超大的二进制数存东西,对于这道题就是用来存那个数能被求出。bitset还用来加速求的过程,bitset|=bitset<<x[i]就直接把原来的数加上新数了(就这里最神奇)

         

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<bitset>
#define mod 10007
#define ll long long
#define Mod 1000007
using namespace std;
ll t,n,m,a,b,c,y,d,e,f,s[200005];
bitset<1000010> ans;
inline ll read()
{
	ll sum=0,f=1;char x=getchar();
	while(x<'0'||x>'9'){if(x=='-')f=-1;x=getchar();}
	while(x>='0'&&x<='9')sum=sum*10+x-'0',x=getchar();
	return sum*f;
}
int yjn()
{
	freopen("animalcupid.in","r",stdin);
	freopen("animalcupid.out","w",stdout);
	t=read();
	while(t--)
	{
		ans.reset();
		ans.set(0);
		n=read();m=read();
		s[0]=read()%mod;a=read()%mod;b=read()%mod;c=read()%mod;
		y=read()%Mod;d=read()%Mod;e=read()%Mod;f=read()%Mod;
		for(int i=1;i<=n;i++)
		{
		   s[i]=(((a%mod)*(s[i-1]%mod)*(s[i-1])%mod)%mod+((b%mod)*(s[i-1]%mod))%mod+c%mod)%mod;
		   ans|=ans<<s[i];
		}
		for(int i=1;i<=m;i++)
		{
			y=((((y%Mod)*(y%Mod))%Mod*(d%Mod))%Mod+((y%Mod)*(e%Mod))%Mod+f%Mod)%Mod;
			if(ans[y])
			   printf("yes\n");
			else
			   printf("no\n");
		}
	}
}
int qty=yjn();
int main(){;}

 

posted @ 2017-10-06 20:19  Hzoi_QTY  阅读(176)  评论(0编辑  收藏  举报