Advertisement
deadwing97

NBONACCI Tester

Mar 25th, 2019
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5.  
  6. const int MX = (1<<20);
  7.  
  8. long long arr[MX] , ans[MX] , pref[MX];
  9.  
  10. void solve(){
  11.  
  12.     int n , Q;
  13.  
  14.     scanf("%d %d",&n,&Q);
  15.  
  16.     vector < int > Queries;
  17.  
  18.     long long tot = 0;
  19.  
  20.     for(int j = 0 ; j < n ; j++){
  21.         scanf("%lld",&arr[j]);
  22.         tot ^= arr[j];;
  23.     }
  24.  
  25.     pref[0] = arr[0];
  26.  
  27.     for(int j = 1 ; j < n ; j++) pref[j] = (arr[j] ^ pref[j-1]);
  28.  
  29.     for(int j = 1 ; j <= Q ; j++){
  30.         int pos;
  31.         scanf("%d",&pos); --pos;
  32.         printf("%lld\n",pref[pos%(n+1)]);
  33.     }
  34.  
  35.  
  36.  
  37.  
  38. }
  39. int main(){
  40.  
  41.     solve();
  42.  
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement