Solution
3426-Sliding_Window_Xor.cpp
1#include<bits/stdc++.h>
2using namespace std;
3#define int long long
4signed main(){
5 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
6 int n,k; cin>>n>>k;
7 int x,a,b,c; cin>>x>>a>>b>>c;
8 queue<int> q;
9 int ans=0;
10 for(int i=0,run=x;i<n;run^=(x=(a*x+b)%c),++i){
11 q.emplace(x);
12 if((int)q.size()>k) run^=q.front(),q.pop();
13 if((int)q.size()==k) ans^=run;
14 }
15 cout<<ans<<'\n';
16 return 0;
17}Editorial not yet generated for this problem. Run the editorial generation script to add hints and detailed explanations.