QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#561546#7679. Master of Both IVprime-idealWA 23ms5828kbC++202.2kb2024-09-12 23:40:182024-09-12 23:40:19

Judging History

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

  • [2024-09-12 23:40:19]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:5828kb
  • [2024-09-12 23:40:18]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define forw(_,l,r) for(auto _=(l);_<(r);++_)
#define fors(_,r,l) for(auto _=(r);_>(l);--_)
#define RN return
#define MT make_tuple
#define fastio cin.tie(0),cout.tie(0),ios::sync_with_stdio(0);
#define clz __builtin_clz

void read(){}
template <typename T,typename...Types>
void read(T& a,Types&...args){
  a=0; char c=' ';
  while(isspace(c))c=getchar();
  while(isdigit(c))a=10*a+c-'0',c=getchar();
  read(args...);
}
typedef long long ll;
const int NUM=2e5+10;
int prime[NUM/5]{},pcnt=0,lp[NUM]{},rem[NUM]{};
char lpc[NUM]{};
int fact[2*int(sqrt(NUM))]{},ftop;
void factor(int x){
	ftop=0;fact[ftop++]=1;
	for(;x!=1;ftop*=(lpc[x]+1),x=rem[x])
		for(int j=0,base=0;j<lpc[x];++j,base+=ftop)
			forw(k,base,base+ftop)fact[ftop+k]=fact[k]*lp[x];
}
void euler(){
	lp[1]=rem[1]=1;
	forw(i,2,NUM){
		if(!lp[i])prime[pcnt++]=i,lp[i]=i,rem[i]=lpc[i]=1;
		int p; ll t;
		for(int j=0;j<pcnt&&(t=i*(p=prime[j]))<NUM;++j){
			lp[t]=p;
			if(i%p)rem[t]=i,lpc[t]=1;
			else{rem[t]=rem[i],lpc[t]=lpc[i]+1;break;}
		}
	}
}
void test(){
	factor(48);
	forw(i,0,ftop)cout<<fact[i]<<' ';
}
int n;set<int> vis;
int cnt[NUM]{},mat[70],rk;
void clear(){
	for(auto x:vis)cnt[x]=0;
	vis.clear();
}
void gaussClear(){memset(mat,0,sizeof(mat));rk=0;}
void gauss(int x){
	forw(i,0,31)if((x>>i)&1){int&r=mat[i];if(r)x^=r;else{r=x;++rk;break;}}
}
const int MOD=998244353;
struct fn{
	int n;fn(int n=0):n(n){}
	fn operator+(fn y){int t=n+y.n;RN t>=MOD?t-MOD:t;}
	fn operator-(fn y){int t=n-y.n;RN t<0?t+MOD:t;}
	fn operator*(fn y){RN int(1LL*n*y.n%MOD);}
	fn ksm(int b){fn r=1;for(fn a=n;b;b/=2,a=a*a)if(b&1)r=r*a;RN r;}
};
fn calc(){
	gaussClear(); int var=0; 
	for(auto x:vis)gauss(x),var+=cnt[x];
	fn ret=fn(2).ksm(var-rk)-1;
	for(auto x:vis){
		gaussClear(); var=0;
		fn mult=fn(2).ksm(cnt[x]-1)-1;
		factor(x);forw(i,0,ftop)gauss(i),var+=cnt[i];
		ret=ret+fn(2).ksm(var-rk);
		if(!mult.n)continue;
		++var,gauss(x);
		ret=ret+fn(2).ksm(var-rk)*mult;
	}RN ret;
}
int main(){
	fastio;
	euler(); //test();
	int t; read(t);
	forw(_,0,t){
		clear();
		read(n);forw(i,0,n){int x;read(x);vis.insert(x);++cnt[x];}
		cout<<calc().n<<endl;
	}
	RN 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 5804kb

input:

2
3
1 2 3
5
3 3 5 1 1

output:

4
11

result:

ok 2 number(s): "4 11"

Test #2:

score: -100
Wrong Answer
time: 23ms
memory: 5828kb

input:

40000
5
4 2 5 5 5
5
5 5 5 5 4
5
1 4 4 4 2
5
2 5 2 4 1
5
3 2 4 5 3
5
1 5 5 3 4
5
5 5 5 4 3
5
4 3 3 5 1
5
4 5 5 2 1
5
2 5 4 2 5
5
3 4 3 4 3
5
5 3 5 1 3
5
5 1 2 4 4
5
4 2 5 1 5
5
5 4 2 5 4
5
5 2 5 2 4
5
1 4 5 4 5
5
4 2 3 2 3
5
1 4 1 3 5
5
1 1 2 1 5
5
5 2 5 1 3
5
3 1 2 5 3
5
5 5 1 1 5
5
2 2 2 1 3
5
3 1 ...

output:

15
27
9
9
13
9
17
9
8
12
23
8
8
8
13
12
14
12
10
15
8
8
17
13
8
11
8
13
13
17
15
9
12
8
8
13
11
9
10
14
14
17
15
15
8
8
8
19
11
8
23
11
10
13
10
14
9
8
12
8
8
15
11
8
17
12
13
9
8
8
12
9
15
11
8
13
9
8
15
13
8
15
13
8
15
15
9
11
23
8
9
11
8
17
11
13
19
13
27
15
13
8
15
12
17
15
27
14
17
15
12
13
9
1...

result:

wrong answer 1st numbers differ - expected: '9', found: '15'