比赛 期末考试0 评测结果 ATTEEEEEEE
题目名称 我能在摸鱼被发现的情况下躲避教练的视奸吗 最终得分 10
用户昵称 张雨晴 运行时间 7.389 s
代码语言 C++ 内存使用 3.57 MiB
提交时间 2026-02-07 11:24:01
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
const long long P=4294967296;
int a[50005],b[50005],c[50005];
int n,m;
//const int MAXSIZE=(1<<25);
//char buf[1<<25],*p1,*p2;
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,MAXSIZE,stdin),p1==p2)?EOF:*p1++)
//inline int read(){
//	int x=0,f=1;char ch=gc();
//	while(!isdigit(ch)){if(ch=='-')f=-1;ch=gc();}
//	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-48,ch=gc();
//	return x*f;
//}
int query(int l,int r){
    int ans_a=a[l];
    int ans_b=b[l];
    int ans_c=c[l];
    
    for(int i=l+1;i<=r;i++){
//        cout<<i<<"\n"; 
        ans_a=(ans_a&a[i]);
        ans_b=(ans_b|b[i]);
        ans_c=(__gcd(ans_c,c[i]));
    }
    return (((ans_a%P)*(ans_b%P))*(ans_c%P))%P; 
}
int main(){
    freopen("shijian.in","r",stdin);
    freopen("shijian.out","w",stdout);
    cin>>n>>m;
//    n=read();
//    m=read();
    for(int i=1;i<=n;i++){
        cin>>a[i];
//        a[i]=read();
    }
    for(int i=1;i<=n;i++){
        cin>>b[i];
//        b[i]=read();
    }
    for(int i=1;i<=n;i++){
        cin>>c[i];
//        c[i]=read();
    }
    for(int i=1;i<=m;i++){
        int l,r;
        cin>>l>>r;
//        l=read();
//        r=read();
        int ans=0;
        for(int j=l;j<=r;j++){
            for(int k=j;k<=r;k++){
                ans+=query(j,k);
//                cout<<ans<<"\n";
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}