题解:CF2225D Exceptional Segments
前言:滚木滚木
Solution
我们先定义一个前缀异或数组
然后考虑
枚举可得满足条件的只有三种情况:
然后分别计算上述三种贡献然后相加就可以了,注意取模不要炸了。
Code
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int M=998244353;
int T,n,x;
int czf(int l,int r,int f){
int fir=l+((f-l)%4+4)%4;
if(fir>r)return 0;
return ((r-fir)/4+1)%M;
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>T;
while(T--){
cin>>n>>x;
int ans=0;
ans=(ans+czf(0,x-1,1)*czf(x,n,1))%M;
ans=(ans+czf(0,x-1,3)*czf(x,n,3))%M;
ans=(ans+czf(x,n,3))%M;
cout<<ans<<'\n';
}
}