Solution
3220-Sliding_Window_Sum.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 arr[n];
8 int a,b,c; cin>>arr[0]>>a>>b>>c;
9 for(int i=1,x=arr[0];i<n;++i) arr[i]=(x*a+b)%c,x=arr[i];
10 int res=0,run=0;
11 for(int i=0;i<k;++i) run+=arr[i];
12 res^=run;
13 for(int i=k;i<n;++i){
14 run+=arr[i]-arr[i-k];
15 res^=run;
16 }
17 cout<<res<<'\n';
18 return 0;
19}Editorial not yet generated for this problem. Run the editorial generation script to add hints and detailed explanations.