Guest User

CookOff-March1

a guest
Mar 29th, 2019
22
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. // printf("%d", 1^5^6^7^5^1^5^6^7^5);
  6. int n,k;
  7. cin>>n>>k;
  8. int a[n+1];
  9. int ans[n+1];
  10. for(int i=0; i<n; i++)
  11. cin>>a[i];
  12.  
  13. a[n] = a[0];
  14. for(int i=1; i<n; i++)
  15. a[n] = a[i]^a[n];
  16.  
  17. ans[0] = a[0];
  18. for(int i=1; i<=n; i++)
  19. ans[i] = ans[i-1]^a[i];
  20.  
  21. // for(int i=0; i<=n; i++)
  22. // cout<<ans[i]<<" ";
  23.  
  24. while(k--)
  25. {
  26. int t;
  27. cin>>t;
  28. cout<<ans[t%(n+1)-1]<<"\n";
  29.  
  30. }
  31.  
  32. }
RAW Paste Data