题解:P11192 [COTS/CETS 2021] 菜 Jelo
Rainbow_qwq · · 题解
假设有
先构造一个
然后对于
这样如果两个 pair
由于在该
由于同时有
那么这样构造就不会有两个不同的 pair 的 xor 相同,并且构造了
// what is matter? never mind.
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
//#define int long long
using namespace std;
int mod;
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 55
#define inf 0x3f3f3f3f
#define poly vector<modint>
int n,p,k;
poly operator +(poly a,poly b){
int n=max(a.size(),b.size());a.resize(n),b.resize(n);
For(i,0,n-1)a[i]+=b[i];return a;
}
poly operator -(poly a,poly b){
int n=max(a.size(),b.size());a.resize(n),b.resize(n);
For(i,0,n-1)a[i]-=b[i];return a;
}
poly operator *(poly a,modint b){
int n=a.size();
For(i,0,n-1)a[i]*=b;return a;
}
poly operator *(poly a,poly b){
if(!a.size()||!b.size())return {};
poly c(a.size()+b.size()-1,0);
for(int i=0;i<a.size();++i)
for(int j=0;j<b.size();++j)
c[i+j]+=a[i]*b[j];
return c;
}
poly operator %(poly a,poly b){
while(b.back().x==0)b.pop_back();
while(1){
while(a.size()&&a.back().x==0)a.pop_back();
if(a.size()<b.size())return a;
int t=a.size()-b.size();
modint w=a.back()/b.back();
For(i,0,(int)b.size()-1)a[i+t]-=b[i]*w;
assert(a.back().x==0);
}
}
void init(poly &a,int x){
if(a.size()<k)a.resize(k);
For(i,0,k-1)a[i]=x%p,x/=p;
}
int get(poly a){
if(a.size()<k)a.resize(k);
int res=0;
Rep(i,k-1,0)res=res*p+a[i].x;
return res;
}
bool chk(poly a){
poly b;
For(i,p,n-1){
init(b,i);
poly c=a%b;
if(!c.size())return 0;
}
return 1;
}
poly qwq(){
poly a(k+1); a[k]=1;
For(i,1,n-1){
init(a,i);
if(chk(a))return a;
}
assert(0);
}
int pri[maxn],pc[maxn],tot;
void fj(int n){
For(i,2,n)
if(n%i==0){
pri[++tot]=i;
while(n%i==0)n/=i,++pc[tot];
}
}
signed main()
{
n=1<<read();
k=0;
while((1<<(k*2))<n)k++;
n=(1<<k);
mod=p=2;
poly a;
a=qwq();//puts("QWQWQ");
// for(auto x:a)cout<<x.x<<' ';puts(" A");
vi o;
int s=(1<<k);
For(i,0,(1<<k)-1){
poly x; init(x,i);
poly y=x*x%a*x%a;
int out=get(y);
out|=(i<<k);
o.pb(out);
}
cout<<o.size()<<"\n";
for(int x:o)cout<<x<<" \n"[x==o.back()];
return 0;
}
// (1 0 1) %