• 2021 ICPC Gran Premio de Mexico 1ra Fecha


    Dashboard - 2021 ICPC Gran Premio de Mexico 1ra Fecha - Codeforces

      我前期做的还行,后期想不出来难题了,惭愧。

      L - Leonel and the powers of two

      一个递归的式子,根据题意模拟即可,开一个返回值为string的函数。

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll read(){ll x;scanf("%lld",&x);return x;}
    string work(ll x)
    {
        if(x==1)
            return "2";
        string s;
        if(x%2==1)
        {
            s=s+"(2*"+work(x-1)+")";
            return s;
        }
        else
        {
            s=s+"("+work(x/2)+")^2";
            return s;
        }
    }
    int main()
    {
        for(ll t=read();t;t--)
            cout<<work(read())<<endl;
    }
    View Code

      C - Cypher Decypher

      询问区间内质数的数量。预处理后用前缀和数组回答询问。

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll read(){ll x;scanf("%lld",&x);return x;}
    ll sum,v[1000010],prime[1000010],c[1000010];
    int main()
    {
        sum=0;
        for(int i=2;i<=1000000;i++)
        {
            if(v[i]==0)
            {
                sum++;
                v[i]=i;
                prime[sum]=i;
            }
            for(int f=1;f<=sum;f++)
            {
                if(prime[f]>v[i]||prime[f]>1000000/i)break;
                v[i*prime[f]]=prime[f];
            }
        }
        for(int i=1;i<=sum;i++)
            c[prime[i]]=1;
        for(int i=1;i<=1000000;i++)
            c[i]+=c[i-1];
        for(ll t=read();t;t--)
        {
            ll l=read(),r=read();
            printf("%lld
    ",c[r]-c[l-1]);
        }
    }
    View Code

      F - Fixing Subtitles

      模拟,利用scanf的格式字符串读入时间相关并处理一下,字幕的内容用while(getline(cin,s))读入并判断是否是标题1、2 、3、 4

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    //freopen("1.in","r",stdin);
    ll read(){ll x;scanf("%lld",&x);return x;}
    int n,x,y,z;
    void work(int &a,int &b,int &c,int &d)
    {
        d=d+y;
        c=c+x+d/1000;
        d=d%1000;
        b=b+c/60;
        c=c%60;
        a=a+b/60;
        b=b%60;
    }
    int now,a,b,c,d;
    string s,kk;
    int main()
    {
    //freopen("1.in","r",stdin);
        scanf("%d %d.%d",&n,&x,&y);
        scanf("%d",&now);
        for(int i=1;i<=n;i++)
        {
            printf("%d
    ",i);
            scanf("%d:%d:%d,%d",&a,&b,&c,&d);
            work(a,b,c,d);
            printf("%02d:%02d:%02d,%03d --> ",a,b,c,d);
            scanf(" --> %d:%d:%d,%d",&a,&b,&c,&d);
            work(a,b,c,d);
            printf("%02d:%02d:%02d,%03d",a,b,c,d);
            kk.clear();
            now=i+1;
            while(now)
            {
                kk=char('0'+now%10)+kk;
                now=now/10;
            }
            while(getline(cin,s))
            {
                if(s==kk)
                    break;
                else
                    cout<<s<<endl;
            }
        }
        
    } 
    View Code

      E - Escape Room

      询问一个地图里的一些点的状态,处理走的点时,先不管方向的顺序LDRU,而是先算出来距离出口的最短距离,然后再循环一遍更新方向的顺序即可。

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    int read(){    int x;scanf("%d",&x);return x;}
    char a[1010][1010],s[1010];
    int n,m,f[1010][1010],v[1010][1010];
    int dx[5]={0,0,-1,0,1},dy[5]={0,1,0,-1,0};
    queue<int>qx,qy;
    int x,y;
    int main()
    {
    //freopen("1.in","r",stdin);
    //freopen("1.out","w",stdout);
        n=read();m=read();
        memset(a,'#',sizeof(a));
        for(int i=1;i<=n;i++)
        {
            scanf("%s",s);
            for(int j=1;j<=m;j++)
                a[i][j]=s[j-1];
        }
        memset(f,0x3f,sizeof(f)); 
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
                if(a[i][j]=='E')
                {
                    f[i][j]=0;
                    qx.push(i);
                    qy.push(j);
                }
        while(qx.size())
        {
            x=qx.front();qx.pop();
            y=qy.front();qy.pop();
            for(int i=1;i<=4;i++)
            {
                if(a[x+dx[i]][y+dy[i]]=='X'||a[x+dx[i]][y+dy[i]]=='#')
                    continue; 
                if(f[x+dx[i]][y+dy[i]]>f[x][y]+1)
                {
                    f[x+dx[i]][y+dy[i]]=f[x][y]+1;
                    v[x+dx[i]][y+dy[i]]=i;
                    qx.push(x+dx[i]);
                    qy.push(y+dy[i]);
                }
            }
        }
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
                for(int k=1;k<=4;k++)
                    if(f[i][j]+1==f[i+dx[k]][j+dy[k]]&&v[i+dx[k]][j+dy[k]]>k)
                        v[i+dx[k]][j+dy[k]]=k;
        for(int q=read();q;q--)
        {
            x=read();y=read();
            if(a[x][y]=='#')
                printf("W
    ");
            else if(a[x][y]=='X')
                printf("X
    ");
            else if(a[x][y]=='E')
                printf("E
    ");
            else if(f[x][y]==f[0][0])
                printf("?
    ");
            else
            {
                if(v[x][y]==1)
                    printf("L
    ");
                else if(v[x][y]==2)
                    printf("D
    ");
                else if(v[x][y]==3)
                    printf("R
    ");
                else
                    printf("U
    ");
            }
        }
    }
    View Code

      然后看浩爹表演即可。

     
     
     
  • 相关阅读:
    每日立会2015-11-30
    Some Modern Softwares' drawbacks: User experience 12/29/2015
    Sprint 5 summary: UI 界面更新,Azure端部署和用户反馈分析 12/28/2015
    Daily Scrum 12/25/2015
    Daily Scrum 12/24/2015
    Daily Scrum 12/23/2015
    Daily Scrum 12/21/2015
    Daily Scrum 12/18/2015
    Daily Scrum 12/17/2015
    Performance standard (ALPHA release) 12/17/2015
  • 原文地址:https://www.cnblogs.com/qywyt/p/15256569.html
Copyright © 2020-2023  润新知