SDNU 1528.Reasoning test 暴力模拟

1528.Reasoning test
Time Limit: 1000 MS    Memory Limit: 32768 KB
Total Submission(s): 4    Accepted Submission(s): 4
Description
In 2018,Jiangsu provincial public security network security team’s official micro-blog "Jiangsu net police" issued a "2018 criminal investigation subject reasoning test questions"


But just think by pen and paper is too hard, so lmh decide to write a program to solve this problem nicely. The following is the original problem. lmh is already know the answer, can you?


(These question all are one answer)


(Math means the –th question, like “2” means “the second question”)


1. The answer of this question is()


A.A  B.B  C.C  D.D


2. The answer of the fifth question is()


A.C  B.D  C.A  D.B


3. Which of the following option’s answer is different from the other three options’ answer?()


A. 3  B. 6  C.2  D. 4


4. Which two following options’ answer are same?()


A. 1 and 5  B.2 and 7  C.1 and 9  D.6 and 10


5. Which the following option’s answer is the same with this question’s answer?()


A.8  B.4  C.9  D.7


6. Which two following options’ answer is the same with the eighth question’s answer?()


A.2 and 4  B.1 and 6  C.3 and 10  D.5 and 9


7.In these ten questions, the least selected options is()


A.C  B.B  C.A  D.D


8.Which of the following option’s answer and the first question’s answer are not adjacent in the alphabet?()


A.7  B.5  C.2  D.10


9.It is known that the two statement of “the first question’s answer is the same with the sixth question’s answer” and “the X-th question’s answer is the same with the fifth question’s answer”, one is true, and another is false. So X is()


A.6  B.10  C.2  D.9


10.In these ten questions, what is the difference between the maximum selected options and the least selected options of A,B,C,D four letters?()


A.3  B.2  C.4  D.1


Input
(No Input)


Output
These ten questions' answer.(Output like "AAAAAAAAAA")


Sample Input
(No Input)
Sample Output

(secret)


    第一次新生选拔赛,因为突然被邀去讲蓝桥杯所以还要准备一下蓝桥杯的题emmm,所以这次我只出了一道题。这道题其实来源于江苏网警的微博发布的一套推理试题,感觉做成编程题的话很好玩,然后就出成了题→ _→ 然而新生好像大都是手算出来的......大概是打比赛打习惯了已经形成惯性思维了吧,看见这一堆东西第一反应就是写个代码算了完全不想动脑子......

    其实这题也没啥好说的,就是暴力pow(4^10)种情况,然后写一个判定的函数,如果暴力出结果直接输出就可以了。

    新生们,期待下一次选拔赛吧~

    下面AC代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<math.h>
using namespace std;
char ans[5]={'A','B','C','D'};
char choice[15]={'0','A','A','A','A','A','A','A','A','A','A'};

int judge()
{
    int i;
    int flag;
    //first

    //second

    if(choice[2]=='A'||choice[2]=='B')
    {
        if(choice[5]!=(char)(choice[2]+2))
            return 0;
    }
    else
    {
        if(choice[5]!=(char)(choice[2]-2))
            return 0;
    }

    //third

    if(choice[3]=='A')
    {
        if(choice[3]!=choice[6]&&choice[6]==choice[2]&&choice[6]==choice[4])
            flag=1;
        else
            return 0;
    }
    else if(choice[3]=='B')
    {
        if(choice[6]!=choice[3]&&choice[3]==choice[2]&&choice[3]==choice[4])
            flag=1;
        else
            return 0;
    }
    else if(choice[3]=='C')
    {
        if(choice[2]!=choice[3]&&choice[3]==choice[6]&&choice[3]==choice[4])
            flag=1;
        else
            return 0;
    }
    else
    {
        if(choice[4]!=choice[3]&&choice[3]==choice[6]&&choice[3]==choice[2])
            flag=1;
        else
            return 0;
    }

    //fourth

    if(choice[4]=='A')
    {
        if(choice[1]!=choice[5])
            return 0;
    }
    else if(choice[4]=='B')
    {
        if(choice[2]!=choice[7])
            return 0;
    }
    else if(choice[4]=='C')
    {
        if(choice[1]!=choice[9])
            return 0;
    }
    else
    {
        if(choice[6]!=choice[10])
            return 0;
    }

    //fifth

    if(choice[5]=='A')
    {
        if(choice[8]!=choice[5])
            return 0;
    }
    else if(choice[5]=='B')
    {
        if(choice[4]!=choice[5])
            return 0;
    }
    else if(choice[5]=='C')
    {
        if(choice[9]!=choice[5])
            return 0;
    }
    else
    {
        if(choice[7]!=choice[5])
            return 0;
    }

    //sixth

    if(choice[6]=='A')
    {
        if(choice[2]!=choice[8]||choice[4]!=choice[8])
            return 0;
    }
    else if(choice[6]=='B')
    {
        if(choice[1]!=choice[8]||choice[6]!=choice[8])
            return 0;
    }
    else if(choice[6]=='C')
    {
        if(choice[3]!=choice[8]||choice[10]!=choice[8])
            return 0;
    }
    else
    {
        if(choice[5]!=choice[8]||choice[9]!=choice[8])
            return 0;
    }

    //seventh

    int aa=0,bb=0,cc=0,dd=0;
    for(i=1;i<=10;i++)
    {
        if(choice[i]=='A')
            aa++;
        else if(choice[i]=='B')
            bb++;
        else if(choice[i]=='C')
            cc++;
        else
            dd++;
    }
    if(choice[7]=='A')
    {
        if(aa>bb||aa>cc||aa>dd)
            return 0;
    }
    else if(choice[7]=='B')
    {
        if(bb>aa||bb>cc||bb>dd)
            return 0;
    }
    else if(choice[7]=='C')
    {
        if(cc>aa||cc>bb||cc>dd)
            return 0;
    }
    else
    {
        if(dd>aa||dd>bb||dd>cc)
            return 0;
    }

    //eighth

    if(choice[8]=='A')
    {
        if(choice[7]-1!=(int)choice[1]&&choice[7]+1!=(int)choice[1])
            flag=1;
        else
            return 0;
    }
    else if(choice[8]=='B')
    {
        if(choice[5]-1!=(int)choice[1]&&choice[5]+1!=(int)choice[1])
            flag=1;
        else
            return 0;
    }
    else if(choice[8]=='C')
    {
        if(choice[2]-1!=(int)choice[1]&&choice[2]+1!=(int)choice[1])
            flag=1;
        else
            return 0;
    }
    else
    {
        if(choice[10]-1!=(int)choice[1]&&choice[10]+1!=(int)choice[1])
            flag=1;
        else
            return 0;
    }

    //ninth

    if(choice[9]=='A')
    {
        if((choice[1]==choice[6]&&choice[6]==choice[5])||(choice[1]!=choice[6]&&choice[6]!=choice[5]))
            return 0;
    }
    else if(choice[9]=='B')
    {
        if((choice[1]==choice[6]&&choice[10]==choice[5])||(choice[1]!=choice[6]&&choice[10]!=choice[5]))
            return 0;
    }
    else if(choice[9]=='C')
    {
        if((choice[1]==choice[6]&&choice[2]==choice[5])||(choice[1]!=choice[6]&&choice[2]!=choice[5]))
            return 0;
    }
    else
    {
        if((choice[1]==choice[6]&&choice[9]==choice[5])||(choice[1]!=choice[6]&&choice[9]!=choice[5]))
            return 0;
    }

    //tenth

    int maxx;
    int minn;
    maxx=max(aa,max(bb,max(cc,dd)));
    minn=min(aa,min(bb,min(cc,dd)));
    if(choice[10]=='A')
    {
        if(maxx-minn!=3)
            return 0;
    }
    else if(choice[10]=='B')
    {
        if(maxx-minn!=2)
            return 0;
    }
    else if(choice[10]=='C')
    {
        if(maxx-minn!=4)
            return 0;
    }
    else
    {
        if(maxx-minn!=1)
            return 0;
    }

    //OK
    return 1;
}

int main()
{
    int i,j;
    int t;
    for(i=0;i<pow(4,10);i++)
    {
        t=i;
        for(j=1;j<=10;j++)
        {
            choice[j]='A'+t%4;
            t=t/4;
        }
        if(judge())
        {
            for(i=1;i<=10;i++)
                cout<<choice[i];
            cout<<endl;
            break;
        }
    }
    return 0;
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值