zoukankan      html  css  js  c++  java
  • Codeforces Round #444 (Div. 2) B. Cubes for Masha

     最多是3个魔方,也就是最多有18个面,可以知道可以得到的最大的x是98,假如是99的话,那么有9个面要是1到9,剩下的9个面要是0到9,但是超过了剩余的面数,然后要是x最大为98的话,前9个面可以安排为1到9,后9个面安排为0到8,刚好9个面,所以可以知道x最大也就是98.

    #include<bits/stdc++.h>
    using namespace std;
    int vis[100];
    int cu[4][7];
    
    int main()
    {
        int n;
        cin>>n;
        memset(vis,0,sizeof(vis));
        for(int i=1;i<=n;i++)
            for(int j=1;j<=6;j++)
                cin>>cu[i][j];
        if(n==1)//枚举出1个魔方可以得到的所有个位数
        {
            for(int i=1;i<=6;i++)
                vis[cu[1][i]]=1;
        }
        else
            if(n==2)//枚举出2个魔方可以得到的所有十位数
            {
                for(int i=1;i<=2;i++)
                    for(int j=1;j<=6;j++)
                        vis[cu[i][j]]=1;
                for(int i=1;i<=6;i++)
                    for(int j=1;j<=6;j++)
                    {
                        int tmp1=cu[1][i],tmp2=cu[2][j],tmp3,tmp4;
                        tmp3=tmp1*10+tmp2;
                        tmp4=tmp2*10+tmp1;
                        vis[tmp3]=1;
                        vis[tmp4]=1;
                    }
    
            }
            else//枚举出3个魔方可以得到的所有十位数
            {
                for(int i=1;i<=3;i++)
                    for(int j=1;j<=6;j++)
                        vis[cu[i][j]]=1;
                for(int i=1;i<=6;i++)
                    for(int j=1;j<=6;j++)
                    {
                        int tmp1=cu[1][i],tmp2=cu[2][j],tmp3,tmp4;
                        tmp3=tmp1*10+tmp2;
                        tmp4=tmp2*10+tmp1;
                        vis[tmp3]=1;
                        vis[tmp4]=1;
                    }
                for(int i=1;i<=6;i++)
                    for(int j=1;j<=6;j++)
                    {
                        int tmp1=cu[1][i],tmp2=cu[3][j],tmp3,tmp4;
                        tmp3=tmp1*10+tmp2;
                        tmp4=tmp2*10+tmp1;
                        vis[tmp3]=1;
                        vis[tmp4]=1;
                    }
                for(int i=1;i<=6;i++)
                    for(int j=1;j<=6;j++)
                    {
                        int tmp1=cu[2][i],tmp2=cu[3][j],tmp3,tmp4;
                        tmp3=tmp1*10+tmp2;
                        tmp4=tmp2*10+tmp1;
                        vis[tmp3]=1;
                        vis[tmp4]=1;
                    }
    
            }
            for(int i=1;i<=99;i++)//从最小的1往后找,第一个没被标记的就是能表示的数的最大值了
                if(!vis[i])
                {
                    
                    cout<<i-1<<endl;
                    return 0;
    
                }
            
    
    }
    
  • 相关阅读:
    hdu2328 Corporate Identity
    hdu1238 Substrings
    hdu4300 Clairewd’s message
    hdu3336 Count the string
    hdu2597 Simpsons’ Hidden Talents
    poj3080 Blue Jeans
    poj2752 Seek the Name, Seek the Fame
    poj2406 Power Strings
    hust1010 The Minimum Length
    hdu1358 Period
  • 原文地址:https://www.cnblogs.com/eason9906/p/11754967.html
Copyright © 2011-2022 走看看