Blue Bridge Cup 2012 tournament Province - strange game

A television station held a low-carbon life Grand Prix. Scoring rules rather strange topic:
Each player needs to answer 10 questions (numbered from 1-10), the more difficult the more behind. The answer, the current score doubled; failed to answer the same question number minus fraction (players must answer questions not answered by error handling).
Each contestant had a starting score of 10 points.
The final score of a winning player is just 100 points, if not let you watch the race, you can infer that he (she) which is the subject answered correctly, which it got it wrong topic?
If the answer is denoted by 1, is referred to as a 0 wrong answer, the answer may be the case 10 containing only topic string of 0 and 1 are represented. For example: 0010110011 is possible.
Your task is to calculate all possible cases. Each answer per line.
Write your answer "answer .txt" Do not write here!

public class lanqiao2012_4 {
	//这题肯定是深度搜索题
	static float count = 10;
	static int [] arr = new  int [10];
	static StringBuffer resl = new StringBuffer("");
	
	public static void  dfs(int i){
	
		if(i==11&&count == 100){	
			String str = Arrays.toString(arr);
			resl.append(str);
			resl.append("\n");
			return;
		}

		if(i==11&&count!=100){
			System.out.println(count);	
			return;
		}
		for(int j = 0;j<=1;j++){
			if(j==0){
				arr[i-1]=0;
				count = count-i;
				dfs(i+1);
				count = count+i;	
				}
			else{
				arr[i-1]=1;
				count = count *2;
				dfs(i+1);
				count = count /2.0f;
				
			}		
		}
		
	}
	public static void main(String[] args) {
		dfs(1);
		System.out.println(resl.toString());
	}

Guess you like

Origin blog.csdn.net/weixin_43752167/article/details/91408979