ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#211859 | #3809. 平方 | drdilyor | 100 | 508ms | 3444kb | C++11 | 1.6kb | 2024-10-07 17:14:42 | 2024-10-07 18:38:52 |
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
void ts(){cout<<"IAKIOI\n";}
inline int read(){
int n=0,f=1,ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
n=n*10+ch-'0';
ch=getchar();
}
return n*f;
}
const int mod=1e9+7;
int n;
int a[10005];
bool p[10005];
int cnt[10005];
int qkp(int b,int pw){
int r=1;
while(pw){
if(pw&1)(r*=b)%=mod;
pw/=2;
(b*=b)%=mod;
}
return r;
}
int w[10005];
int l;
int pr[10005];
int len;
bool b[3200][3200];
signed main(){
n=read();
for(int i=2;i<=n;i++){
if(!p[i]){
pr[++len]=i;
for(int j=i*2;j<=n;j+=i)p[j]=1;
}
}
for(int i=1;i<=n;i++)a[i]=read();
for(int i=1;i<=n;i++){
int x=i;
int r=1;
for(int j=2;j<=n;j++){
if(!p[j]){
int c=0;
while(x%j==0)x/=j,c++;
if(c&1)r*=j;
}
}
cnt[r]+=a[i];
}
int coef=qkp(2,cnt[1]);
for(int i=2;i<=n;i++){
if(!cnt[i])continue;
w[++l]=i;
coef*=qkp(2,cnt[i]-1);coef%=mod;
}
for(int i=1;i<=len;i++){
//x[1]*contain(pr[i])+x[2]+...
for(int j=1;j<=l;j++){
if(w[j]%pr[i]==0){
b[i][j]=1;
}
}
//考虑选择若干个. 使得加起来和是 mod 2 为 0 的.
}
//自由元个数
int v=1;
for(int i=1;i<=l;i++){
for(int j=v;j<=len;j++){
if(b[j][i]){
if(j!=v){
for(int k=1;k<=l;k++)swap(b[j][k],b[v][k]);
}
for(int k=v+1;k<=len;k++){
if(b[k][i]){
for(int x=1;x<=l;x++)b[k][x]^=b[v][x];
}
}
v++;break;
}
}
}
cout<<(qkp(2,l-v+1)*coef%mod+mod-1)%mod<<"\n";
return 0;
}
//look at my code
//my code is amazing
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 0ms
memory: 1204kb
input:
12 2 2 1 2 2 2 1 2 1 2 2 1
output:
32767
result:
ok single line: '32767'
Test #2:
score: 5
Accepted
time: 1ms
memory: 1212kb
input:
21 6071 63571 70449 84192 57749 63236 82243 16019 98823 69250 95932 44671 76920 1666 56759 63797 648...
output:
907130596
result:
ok single line: '907130596'
Test #3:
score: 5
Accepted
time: 0ms
memory: 1208kb
input:
21 78070 53308 73131 49008 73223 91635 38770 85297 83190 39966 6535 12302 86455 15079 69516 35452 51...
output:
805058470
result:
ok single line: '805058470'
Test #4:
score: 5
Accepted
time: 0ms
memory: 1216kb
input:
33 35253 15438 45783 71029 3464 55562 30300 98250 91277 30754 11674 56865 29791 79077 23593 76795 12...
output:
417265909
result:
ok single line: '417265909'
Test #5:
score: 5
Accepted
time: 0ms
memory: 1216kb
input:
33 14031 20789 70420 49867 25529 65501 21352 91592 59302 81424 15091 80896 77254 33600 96383 93040 5...
output:
159573572
result:
ok single line: '159573572'
Test #6:
score: 5
Accepted
time: 0ms
memory: 1240kb
input:
69 2277 90628 50971 84997 47731 58491 19590 74491 87059 48528 19450 65425 86171 98793 53240 80874 99...
output:
707904026
result:
ok single line: '707904026'
Test #7:
score: 5
Accepted
time: 0ms
memory: 1240kb
input:
69 6929 54762 47684 30491 63013 85382 58761 85482 54656 20874 52114 13167 68239 91992 60774 5725 631...
output:
60461118
result:
ok single line: '60461118'
Test #8:
score: 5
Accepted
time: 0ms
memory: 1292kb
input:
139 62883 20064 72746 22914 47638 63229 46693 77251 78236 615 24875 13385 17824 91084 216 55070 9832...
output:
602628280
result:
ok single line: '602628280'
Test #9:
score: 5
Accepted
time: 1ms
memory: 1292kb
input:
139 19629 38452 31587 31200 1869 6696 18434 59574 94450 11252 30525 87152 78094 86067 98721 62927 56...
output:
338896740
result:
ok single line: '338896740'
Test #10:
score: 5
Accepted
time: 0ms
memory: 1392kb
input:
312 70754 34698 434 7024 81418 37867 43301 45062 55942 77685 1947 49600 54159 99924 53272 31135 1756...
output:
777340222
result:
ok single line: '777340222'
Test #11:
score: 5
Accepted
time: 1ms
memory: 1392kb
input:
312 12238 62101 38093 35253 92243 46623 83863 23871 48000 1097 1388 64677 89840 48843 14477 63405 21...
output:
153458268
result:
ok single line: '153458268'
Test #12:
score: 5
Accepted
time: 0ms
memory: 1392kb
input:
312 65902 15679 97624 23389 1670 29206 1712 34607 36006 72210 34479 63586 47142 46925 66200 62562 94...
output:
290367783
result:
ok single line: '290367783'
Test #13:
score: 5
Accepted
time: 8ms
memory: 1848kb
input:
1234 46686 11939 57055 17773 24469 47283 582 90402 27842 94874 61013 1020 28443 75832 33798 22291 20...
output:
857721959
result:
ok single line: '857721959'
Test #14:
score: 5
Accepted
time: 8ms
memory: 1844kb
input:
1234 89657 93796 12385 56406 36479 74685 90947 11817 80881 79329 14528 23593 77641 70991 30841 27849...
output:
878286890
result:
ok single line: '878286890'
Test #15:
score: 5
Accepted
time: 6ms
memory: 1844kb
input:
1234 26692 21448 75529 67905 19536 62310 42976 55776 64574 65478 36252 31679 45062 47707 31881 88564...
output:
163697308
result:
ok single line: '163697308'
Test #16:
score: 5
Accepted
time: 70ms
memory: 3016kb
input:
4021 66995 6713 36815 57369 44032 62055 95975 29509 73258 33818 23360 74155 41951 4813 39228 48076 9...
output:
235980641
result:
ok single line: '235980641'
Test #17:
score: 5
Accepted
time: 66ms
memory: 3016kb
input:
4021 78965 97182 64913 97851 50137 84422 11931 50279 43224 57995 41056 98897 21489 38558 18113 3233 ...
output:
49297200
result:
ok single line: '49297200'
Test #18:
score: 5
Accepted
time: 79ms
memory: 3016kb
input:
4021 60148 5548 69611 73408 50792 67625 97878 48790 50897 56905 13105 19252 35169 541 2594 94014 514...
output:
978843838
result:
ok single line: '978843838'
Test #19:
score: 5
Accepted
time: 131ms
memory: 3444kb
input:
5123 77728 68936 11371 45534 25976 11734 48963 5558 35198 28029 2396 95361 74072 72459 81788 38528 6...
output:
48580309
result:
ok single line: '48580309'
Test #20:
score: 5
Accepted
time: 137ms
memory: 3444kb
input:
5123 34879 51531 20100 53943 82673 4948 38474 13579 19262 38324 28806 50542 93369 76646 80881 16857 ...
output:
695529627
result:
ok single line: '695529627'
Extra Test:
score: 0
Extra Test Passed