求助70pts 总是输出"Too large"
查看原帖
求助70pts 总是输出"Too large"
401052
Endline楼主2022/10/3 21:37

rt

#include<bits/stdc++.h>
const int INF=0x7fffffff;
#define MAXN 200002
#define mod 1000007
#define eps 1e-6
#define ll long long
#define ls(x) x<<1
#define rs(x) x<<1|1
using namespace std;
namespace FastIO
{
    char buf[1<<23],*p1,*p2;
    #ifdef ONLINE_JUDGE
    inline char gc(){return (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<22,stdin),p1==p2))?EOF:*p1++;}
    #else
    inline char gc(){return getchar();}
    #endif
    inline int read()
    {
        int f=1,w=0;char ch=gc();
        while(!isdigit(ch)){if(ch=='-')f=-1;ch=gc();}
        while(isdigit(ch))w=w*10+ch-'0',ch=gc();
        return f*w;
    }
}
using FastIO::read;  
using FastIO::gc;
ll n,q;
ll a[MAXN];
int main()
{
    // freopen("T1ex2.in","r",stdin);
    // freopen("out.out","w",stdout);
    n=read(),q=read();
    for(int i=1;i<=n;i++)
        a[i]=read();
    for(int i=1;i<=q;i++)
    {
        int opt=read(),l=read(),r=read();
        if(opt==1)a[l]=r;
        if(opt==2)
        {
            if(l>r)puts("1");
            else if(l==r)printf("%lld\n",max(1ll,a[l]));
            else if(r-l>61)puts("Too large");
            else
            {
                ll multi,res=-INF;
                for(int i=l;i<=r;i++)
                {
                    multi=1;
                    for(int j=i;j<=r;j++)
                        multi*=a[j],res=max(res,multi);
                }
                if(res>1073741824ll)puts("Too large");
                else printf("%lld\n",res);
            }
        }
    }
    return 0;
}
2022/10/3 21:37
加载中...