Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
28963 | LYLAKIOI | 【BJ】T3 | C++ | 解答错误 | 0 | 176 MS | 16664 KB | 1206 | 2024-05-01 16:41:15 |
#include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) #define p_b push_back #define pi pair<int,int> #define p1 first #define p2 second #define m_p make_pair using namespace std; typedef long long ll; const int maxn=1e6+10,mod=998244353; inline ll read(){ ll x=0;short t=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; }int n,a[maxn],dp[maxn][2][2]; void slv(){ n=read();up(i,1,n)a[i]=read(); ll res=1; down(j,30,0){ memset(dp,0,sizeof(dp)); dp[0][0][0]=1; up(i,0,n-1){ int x=a[i+1]; int c1=0,c2=0; if(a[i+1]>=(1<<j))a[i+1]^=(1<<j),c1=a[i+1]+1,c2=(1<<j); else c1=0,c2=a[i+1]+1; up(j,0,1)up(k,0,1){ (dp[i+1][j^1][1]+=dp[i][j][k]*1ll*c1%mod)%=mod; (dp[i+1][j][k]+=dp[i][j][k]*1ll*c2%mod)%=mod; } }(res+=dp[n][0][1])%=mod; }cout<<res; }int main(){ // freopen("1.in","r",stdin); slv(); fclose(stdin); fclose(stdout); return 0; }