Advertisement
Guest User

Xor

a guest
Dec 11th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4.  
  5. {
  6.  
  7. int q,i;
  8.  
  9. scanf("%d",&q);
  10.  
  11. while(q!=0)
  12.  
  13. {
  14.  
  15. long long int l,r,res;
  16.  
  17. scanf("%lld%lld",&l,&r);
  18.  
  19. int a[r+1];
  20.  
  21. a[0]=0;
  22.  
  23. for(long long int i=1;i<=r;i++)
  24.  
  25. a[i]=a[i-1]^i;
  26.  
  27. res=0;
  28.  
  29. for(long long int i=l;i<=r;i++)
  30.  
  31. res=res^a[i];
  32.  
  33. printf("%lld\n",res);
  34.  
  35. q--;
  36.  
  37. }
  38.  
  39. return 0;
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement