Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define endl '\n'
- using namespace std;
- const int mod=1e9+7;
- //Note:
- // 1.Perform binary search on sorted array only.
- // 2.For ceil caculations we can use something like ceil(10/(double)3)-->>4
- #define ff first
- #define ss second
- #define pb push_back
- #define int long long
- #define MOD 1000000007
- #define mod 1000000007
- #define mod2 998244353
- #define inf 1e18
- #define ps(x,y) fixed<<setprecision(y)<<x
- #define ll long long
- #define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
- const int N = 200005;
- bool myCompare(int a,int b)
- {
- return a>b;
- }
- void solve() {
- int n,q,l,r;
- cin>>n;
- vector<int>v(n);
- for(int i=0;i<n;i++) cin>>v[i];
- cin>>q;
- while(q--)
- {
- int ans=1;
- int xxor,flag=0;
- cin>>l>>r;
- l--;
- r--;
- int limit=r-l+1;
- if(limit>101)
- ans=0;
- else{
- for(int i=l;i<r;i++)
- {
- for(int j=i+1;j<=r;j++){
- xxor=v[i]^v[j];
- ans*=xxor;
- if(ans>=mod)
- ans=ans%mod;
- }
- }}
- cout<<ans<<endl;
- // cout<<ans<<" ";
- }
- }
- signed main()
- {
- ios;
- int test;
- test=1;
- int tc=1;
- // factorial(N-1);
- // InvFactorial(N-1);
- // SieveOfEratosthenes(N-1);
- // cin>>test;
- while(test--)
- {
- //cout<<"Case #"<<tc<<": ";
- //tc++;
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement