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);