Advertisement
Guest User

Untitled

a guest
Apr 26th, 2021
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define endl '\n'
  3. using namespace std;
  4. const int mod=1e9+7;
  5. //Note:
  6. // 1.Perform binary search on sorted array only.
  7. // 2.For ceil caculations we can use something like ceil(10/(double)3)-->>4
  8.  
  9.  
  10. #define ff first
  11. #define ss second
  12. #define pb push_back
  13. #define int long long
  14. #define MOD 1000000007
  15. #define mod 1000000007
  16. #define mod2 998244353
  17. #define inf 1e18
  18. #define ps(x,y) fixed<<setprecision(y)<<x
  19. #define ll long long
  20. #define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  21.  
  22. const int N = 200005;
  23.  
  24.  
  25. bool myCompare(int a,int b)
  26. {
  27. return a>b;
  28. }
  29.  
  30.  
  31. void solve() {
  32. int n,q,l,r;
  33. cin>>n;
  34. vector<int>v(n);
  35. for(int i=0;i<n;i++) cin>>v[i];
  36.  
  37. cin>>q;
  38. while(q--)
  39. {
  40. int ans=1;
  41. int xxor,flag=0;
  42. cin>>l>>r;
  43. l--;
  44. r--;
  45. int limit=r-l+1;
  46. if(limit>101)
  47. ans=0;
  48. else{
  49. for(int i=l;i<r;i++)
  50. {
  51. for(int j=i+1;j<=r;j++){
  52. xxor=v[i]^v[j];
  53. ans*=xxor;
  54. if(ans>=mod)
  55. ans=ans%mod;
  56. }
  57. }}
  58. cout<<ans<<endl;
  59.  
  60. // cout<<ans<<" ";
  61.  
  62.  
  63. }
  64.  
  65.  
  66. }
  67.  
  68. signed main()
  69. {
  70. ios;
  71. int test;
  72. test=1;
  73. int tc=1;
  74. // factorial(N-1);
  75. // InvFactorial(N-1);
  76.  
  77. // SieveOfEratosthenes(N-1);
  78. // cin>>test;
  79.  
  80. while(test--)
  81. {
  82. //cout<<"Case #"<<tc<<": ";
  83. //tc++;
  84. solve();
  85. }
  86.  
  87.  
  88. return 0;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement