QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#299685#6512. Completely Multiplicative Function111445#WA 5ms3808kbC++23793b2024-01-07 04:34:142024-01-07 04:34:15

Judging History

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

  • [2024-01-07 04:34:15]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:3808kb
  • [2024-01-07 04:34:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define b(x) (1ll<<((x)-1))
#define N 1000000

int i,j,k,n,m,t;
bitset<N+50> f;
vector<int> p;

void fuck(int n,int m){
	int i,j,k,tot=0;
	
	for(i=1;i<=n;i++)f[i]=0;
	for(auto i:p){
		if(i>n)break;
		k=0;
		for(j=i;j<=n;j+=i){
			if(!f[j])k++;
			else k--;
		}
		if(tot+k<=m){
			tot+=k;
			for(j=i;j<=n;j+=i)f[j]=(f[j]^1);
		}
		if(tot==m)break;
	}
	if(tot!=m)exit(1);
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	for(i=2;i<=N;i++)if(!f[i]){
		p.push_back(i);
		for(j=i;j<=N;j+=i)f[j]=1;
	}
	f.reset();
	
	cin>>t;
	while(t--){
		cin>>n>>m;
		m=n-m;
		if(m&1){cout<<"-1\n"; continue;}
		m/=2;
		fuck(n,m);
		for(i=1;i<=n;i++)cout<<(f[i]?-1:1)<<' ';
		cout<<'\n';
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 5ms
memory: 3808kb

input:

4
4 2
10 0
10 1
10 10

output:

1 1 -1 1 
1 -1 1 -1 1 -1 1 -1 1 -1 
-1
1 1 1 1 1 1 1 1 1 1 

result:

wrong answer f[4] != f[2] * f[2] (test case 2)