zoukankan      html  css  js  c++  java
  • 2021牛客国庆集训派对day6 J

    看到10000000个数中求最大的lcm感觉很难,但是数据随机

    于是搞一百个最大的数字,100*100扫一遍就稳了(滑稽

    #include <bits/stdc++.h>
    using namespace std;
    typedef int ll;
    inline ll read()
    {
        ll s=0; bool f=0; char ch=' ';
        while(!isdigit(ch)) {f|=(ch=='-'); ch=getchar();}
        while(isdigit(ch)) {s=(s<<3)+(s<<1)+(ch^48); ch=getchar();}
        return (f)?(-s):(s);
    }
    #define R(x) x=read()
    inline void write(ll x)
    {
        if(x<0) {putchar('-'); x=-x;}
        if(x<10) {putchar(x+'0'); return;}
        write(x/10); putchar((x%10)+'0');
    }
    #define W(x) write(x),putchar(' ')
    #define Wl(x) write(x),putchar('
    ')
    const int N=105;
    #define ull unsigned long long 
    unsigned T,n,A,B,C,x,y,z;
    ull a[N];
    inline unsigned tang()
    {
        unsigned t;
        x^=x<<16;
        x^=x>>5;
        x^=x<<1;
        t=x;
        x=y;
        y=z;
        z=t^x^y;
        return z;
    }
    inline ull gcd(ull x,ull y)
    {
        return (y==0)?(x):(gcd(y,x%y));
    }
    signed main()
    {
        unsigned i,j,t,wwx,cnt;
        ull lwj;
        scanf("%u",&T);
        for(t=1;t<=T;t++)
        {
            scanf("%u%u%u%u",&n,&A,&B,&C);
            x=A; y=B; z=C;
            cnt=0; lwj=0;
            priority_queue<ull,vector<ull>,greater<ull> >pq;
            for(i=1;i<=100;i++) pq.push(0);
            for(i=1;i<=n;i++)
            {
                wwx=tang();
                if(wwx>pq.top())
                {
                    pq.pop();
                    pq.push(wwx);
                }
            }
            while(pq.size()>0)
            {
                if(pq.top()!=0)
                {
                    a[++cnt]=pq.top();
                }
                pq.pop();
            }
            for(i=1;i<=min(n,cnt)-1;i++)
            {
                for(j=i+1;j<=min(n,cnt);j++)
                {
                    lwj=max(lwj,a[i]/gcd(a[i],a[j])*a[j]);
                }
            }
            printf("Case #%d: %llu
    ",t,lwj);
        }
        return 0;
    }
    View Code
    河田は河田、赤木は赤木……。 私は誰ですか。教えてください、私は誰ですか。 そうだ、俺はあきらめない男、三井寿だ!
  • 相关阅读:
    [CERC2015]Digit Division
    [SDOI2012]拯救小云公主
    [不知道出自什么OJ]最大利润
    [USACO08FEB]修路Making the Grade
    P1985 [USACO07OPEN]翻转棋
    P1156 垃圾陷阱
    奶酪
    扫描线
    php数组
    php switch
  • 原文地址:https://www.cnblogs.com/gaojunonly1/p/15418378.html
Copyright © 2011-2022 走看看