首页 > 其他 > 详细

URAL 2011. Long Statement题解

时间:2018-08-12 16:28:26      阅读:129      评论:0      收藏:0      [点我收藏+]

传送门


题意:有N个为1或2或3的数,问用这N个数的排列方式是不是有6中以上。


思路:降智题,显然六个数以上无论这六个数是怎么组成,只要有两种数字就一定能组成6种,5种及以下我就懒得找规律了,直接全排列统计。


AC程序

using namespace std;
const int maxn=105;
int a[maxn],n,ans;
set<int> se;
map<string,bool> ma;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        se.insert(a[i]);
    }
    if(n>=6)
    {
        if(se.size()>=2)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        else
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    sort(a,a+n);
    do
    {
        string s="";
        for(int i=0;i<n;i++)
        {
            s=s+char(a[i]+'0');
        }
        if(!ma[s])
        {
            ans++;
            ma[s]=1;
        }
    }while(next_permutation(a,a+n));
    if(ans>=6)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}

URAL 2011. Long Statement题解

原文:https://www.cnblogs.com/NightRaven/p/9463052.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!