QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#556676 | #8520. Xor Partitions | Mu_Silk# | WA | 1ms | 8008kb | C++20 | 939b | 2024-09-10 20:08:05 | 2024-09-10 20:08:06 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M=1e9+7;
const int N=300010;
ll dp[N],sumdp[N],sumdpi[N],fsum[N][64],a[N];
void solve(){
int n;cin>>n;
for(int i=1;i<=n;i++)cin>>a[i],a[i]^=a[i-1];
dp[0]=1;
sumdp[0]=1;
for(int i=1;i<=n;i++){
dp[i]=sumdp[i-1]*(a[i]%M)%M;
dp[i]=(dp[i]+sumdpi[i-1])%M;
for(int j=0;j<=60;j++){
dp[i]=(dp[i]-((a[i]>>j&1)<<(j+1))%M*fsum[i-1][j]%M+M)%M;
}
sumdp[i]=(sumdp[i-1]+dp[i])%M;
sumdpi[i]=(sumdpi[i-1]+dp[i]*(a[i])%M)%M;
for(int j=0;j<=60;j++){
fsum[i][j]=(fsum[i-1][j]+dp[i]*(a[i]>>j&1))%M;
}
}
// for(int i=1;i<=n;i++)cout<<dp[i]<<" ";
// cout<<"\n";
cout<<dp[n]<<"\n";
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n=1;
// cin>>n;
while(n--)solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 7680kb
input:
4 7 3 1 2
output:
170
result:
ok 1 number(s): "170"
Test #2:
score: 0
Accepted
time: 1ms
memory: 7684kb
input:
1 0
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 1ms
memory: 7716kb
input:
1 1
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 1ms
memory: 7816kb
input:
3 1 2 3
output:
16
result:
ok 1 number(s): "16"
Test #5:
score: 0
Accepted
time: 1ms
memory: 7684kb
input:
4 0 1 0 1
output:
2
result:
ok 1 number(s): "2"
Test #6:
score: -100
Wrong Answer
time: 1ms
memory: 8008kb
input:
562 918479109239293921 960173570446350728 374394588863436385 418106819278123099 473761712658352147 662782574081105364 824954323015093862 827581845536521847 184394794881199801 820907621998888642 606529830885621237 961790689782125501 582742201855597942 337901250755571075 287706594894797714 18578215893...
output:
53555317
result:
wrong answer 1st numbers differ - expected: '641941658', found: '53555317'