The 4th Blue Bridge Cup Javab Group Provincial Tournament - Revitalizing China

tags: notes  java

The 4th Blue Bridge Cup Javab Group Provincial Tournament - Revitalizing China

Topic description

Xiaoming participated in the fun gain of the school, one of which is: jumping.

Painted some plaids on the ground, write a word in each lattice, as shown below:

From me
I am making a revitalization
Start in revitalization
Vain

When the game, first stand in the upper left corner of the "from" on the lattice, you can jump to adjacent plaids laterally or longitudinally, but you cannot jump to the diagonal lattice or other location. Always jump to the word "Hua" word.

The route that is required to jump is just a word "starting to revitalize China".

Please help Xiao Ming calculate how many possible jumping routes?

The answer is an integer, please submit the number directly via the browser.
Note: Do not submit a solution process, or other auxiliary instructions.

Solution process

Because the data structure is not good ... So this topic did not think of using deep search ideas (DFS), but tried to use violent solution to solve the problem, try to use a two-dimensional array, use 1, 2, 3 , 4 ... nine numbers represent nine Chinese characters, then find it in order ... However, it is difficult to achieve ...
Then, by analyzing the recursive writing method of depth search, some depth search related content is checked.
Link:Depth priority search algorithm
Currently, only the example of this big, is mainly how to construct a four-digit number of each digit in the four digits of 1, 2, 3, and 4.
(PS: I feel uncomfortable ... I will find some big blog later.)

Point

return dfs(i + 1, j) + dfs(i, j + 1);
I feel that this recursive is the core content, because the data structure is not good ... so I understand the thoroughly spending a good job ...
First, you can observe the pictures in the topic, you can know that the route is only right and lower, and as long as any of the options have reached the end, it can be determined as a choice. I don't understand why I've detrimented endless ways ...

Code


public class Main {
 
	public static void main(String[] args) {
		int ans = 0;
		ans = dfs(0, 0);
		System.out.println(ans);
	}
 
	public static int dfs(int i, int j) {
		if (i == 3 || j == 4) {
			return 1;
		}
		return dfs(i + 1, j) + dfs(i, j + 1);
	}
}

I feel that I have a lot of simple things.
I slept!

Intelligent Recommendation

[The 4th Blue Bridge Cup] Revitalizing China

Topic: Revitalizing China Xiao Ming participated in the school's fun sports meeting, and one of the items was: skip the grid. Draw some grids on the ground, and write a word in each grid, as shown bel...

The 4th Blue Bridge Cup: Revitalizing China

Begin Record your own learning process ~~ Topic Revitalize China Xiaoming participated in the school's fun gain, one of which is: jumping. Draw some plaid on the ground, write a word in each lattice, ...

2018 Blue Bridge Cup Provincial Tournament javaB group-increasing triple

Topic: Incremental triples Given three integer arrays A = [A1, A2, … AN], B = [B1, B2, … BN], C = [C1, C2, … CN], Please count how many triples (i, j, k) satisfy: 1 <= i, j, k ...

2017 Blue Bridge Cup Provincial Tournament JavaB Group

1. Title: Shopping list Xiao Ming just got a job. The boss is very nice, but the boss's wife loves shopping. When the boss is busy, he often asks Xiao Ming to help him go shopping on his behalf. Xiao ...

2016 Blue Bridge Cup Provincial Tournament JavaB Group

1. Number of briquettes There is a pile of briquettes, piled into a triangular pyramid. specific: Put 1 on the first layer, 3 in the second layer (arranged in a triangle), 6 in the third layer (arrang...

More Recommendation

Blue Bridge Cup 2017 Provincial Tournament [Eighth] -JAVAB group analysis (on)

Blue Bridge Cup 2016 Provincial Tournament [Seventh] -Javab Group Analysis Blue Bridge Cup official explaining video:https://www.lanqiao.cn/courses/2737 Zhen Question Document:https://www.lanqiao.cn/c...

Blue Bridge Cup 2015 Provincial Tournament [Sixth] -Javab Group Analysis

Refer to the junction and official code given by the official website of the Blue Bridge Cup. Blue Bridge Cup official explaining video:https://www.lanqiao.cn/courses/2737 Zhen Question Document:https...

The 12th Blue Bridge Cup Provincial Tournament Javab Group Zhenti Sharing

Fill blank questions A. ASC B. Card C. Line D. Food placed E. Path Programming questions F. Time display G. minimum weight H. Yang Hui triangle I. Two-way sort J. Parentheses sequence Fill blank quest...

The 8th Blue Bridge Cup Provincial Tournament Javab Group

shopping list Idea: Take out the calculator or calculate the data, pay attention to only 100 at least 100, the result is 5136.85, should take 5200 Answer: 5200 Card triangle Answer: 144 analysis: The ...

Tenth Blue Bridge Cup Provincial Tournament Javab Group

The maximum value of each column can be added, and the same person can only take it once. Two cycles use havehset to store different non-empty characters. Iterate the item 20190324 The triple cycle en...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top