QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#106465#2072. Junk ProblemCrysflyWA 10ms3420kbC++174.1kb2023-05-17 20:47:502023-05-17 20:47:52

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-17 20:47:52]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:3420kb
  • [2023-05-17 20:47:50]
  • 提交

answer

// 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;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

int mod;
struct modint{
	int x;
	modint(int o=0){x=o;}
	modint &operator = (int o){return x=o,*this;}
	modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
	modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
	modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
	modint &operator ^=(int b){
		modint a=*this,c=1;
		for(;b;b>>=1,a*=a)if(b&1)c*=a;
		return x=c.x,*this;
	}
	modint &operator /=(modint o){return *this *=o^=mod-2;}
	friend modint operator +(modint a,modint b){return a+=b;}
	friend modint operator -(modint a,modint b){return a-=b;}
	friend modint operator *(modint a,modint b){return a*=b;}
	friend modint operator /(modint a,modint b){return a/=b;}
	friend modint operator ^(modint a,int b){return a^=b;}
	friend bool operator ==(modint a,int b){return a.x==b;}
	friend bool operator !=(modint a,int b){return a.x!=b;}
	bool operator ! () {return !x;}
	modint operator - () {return x?mod-x:0;}
	bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}

vector<modint> fac,ifac,iv;
inline void initC(int n)
{
	if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
	int m=iv.size(); ++n;
	if(m>=n)return;
	iv.resize(n),fac.resize(n),ifac.resize(n);
	For(i,m,n-1){
		iv[i]=iv[mod%i]*(mod-mod/i);
		fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
	}
}
inline modint C(int n,int m){
	if(m<0||n<m)return 0;
	return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}

#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=read();
	if(n<=2){
		cout<<n<<endl;
		For(i,1,n)cout<<i<<" ";
		exit(0);
	}
	int s=floor(sqrt(0.5*n));
	while(s>(1<<k)-1)++k;
	n=(1<<k);
	mod=p=2;
	poly a;
	a=qwq();//puts("QWQWQ");
//	for(auto x:a)cout<<x.x<<' ';puts(" A");
	vi o;
	For(i,1,s){
		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()];
//	set<int>S;
//	For(i,0,s-1)
//		For(j,i+1,s-1){
//			if(S.count(o[i]^o[j])) assert(0);
//			S.insert(o[i]^o[j]);
//		}
	return 0;
}
// (1 0 1) % 

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3296kb

input:

49

output:

4
9 19 28 37

result:

ok AC

Test #2:

score: 0
Accepted
time: 7ms
memory: 3420kb

input:

10000000

output:

2236
4097 8200 12303 16448 20565 24696 28779 33280 37449 41640 45799 50112 54173 58200 62211 65545 69912 74305 78678 83273 87116 91953 95794 101897 106320 109793 114110 117449 121732 124945 129370 131144 136297 141504 146663 147969 153140 158393 163466 166490 171571 172658 177693 182675 187886 18881...

result:

ok AC

Test #3:

score: 0
Accepted
time: 6ms
memory: 3412kb

input:

8388607

output:

2047
2049 4104 6159 8256 10325 12408 14443 16896 19017 21160 23271 25536 27549 29528 31491 32778 35099 37442 39765 42314 44111 46898 48689 50703 53078 54503 56760 58063 60290 61463 63836 65616 68721 69853 72954 74266 77359 78503 81556 82497 85544 86636 89603 90507 93686 94614 97773 98406 101719 1030...

result:

ok AC

Test #4:

score: 0
Accepted
time: 10ms
memory: 3320kb

input:

8396802

output:

2049
4097 8200 12303 16448 20565 24696 28779 33280 37449 41640 45799 50112 54173 58200 62211 65545 69912 74305 78678 83273 87116 91953 95794 101897 106320 109793 114110 117449 121732 124945 129370 131144 136297 141504 146663 147969 153140 158393 163466 166490 171571 172658 177693 182675 187886 18881...

result:

ok AC

Test #5:

score: 0
Accepted
time: 2ms
memory: 3328kb

input:

1

output:

1
1 

result:

ok AC

Test #6:

score: 0
Accepted
time: 0ms
memory: 3328kb

input:

2

output:

2
1 2 

result:

ok AC

Test #7:

score: 0
Accepted
time: 2ms
memory: 3328kb

input:

4

output:

1
3

result:

ok AC

Test #8:

score: -100
Wrong Answer
time: 2ms
memory: 3332kb

input:

8

output:

2
5 9

result:

wrong answer Integer parameter [name=a[i]] equals to 9, violates the range [1, 8]