2012 Waterloo Cup question fourth question __ Waterloo Cup question

Source: Internet
Author: User

A TV station held a Low-carbon Life Grand Prix. The scoring rules for the topic are rather strange:

Each contestant needs to answer 10 questions (numbered 1 to 10), which is more difficult to follow. Correct, the current score doubled, the wrong answer is deducted the same score as the title (the player must answer the question, do not answer the wrong
error treatment).

Each contestant has a starting score of 10 points. The winner of the

final score is just 100 points, if you do not let you see the game process, you can infer that he (she) which question is correct, which question answer wrong? If the correct answer is 1 and the wrong answer is

0, then the answers to 10 questions can be expressed in strings that contain only 1 and 0. For example: 0010110011 is a possible situation.

your job is to figure out all the possibilities. Each answer occupies one row
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int ans[10];

void Play (int time,int score)
{
    int k;
    if (time==10)
    {
        if (score==100)
        {
            for (k=0;k<10;k++)
            printf ("%d", ans[k]);
            printf ("\ n")
        ;
    }
    else
    {
        ans[time]=1;
        Play (time+1,score*2);
        ans[time]=0;
        Play (time+1,score-time-1);
    }

int main ()
{
    memset (ans,0,sizeof (ans));
    Play (0,10);
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.