The 8th Blue Bridge Cup (National Competition)

1, square tens

The 10 digits from 0 to 9 are not repeated or omitted, and can be composed of many 10 digits. Many of these also happen to be square numbers (the square of a certain number). For example: 1026753849 is the smallest square number among them. Please find out the largest square number among them? Note: You need to submit a 10-digit number, do not fill in any extra content.

Result: 19028547136
0-9 are arranged in full, composed of ten digits, whether the sqrt function in Math is an integer, judge

static int arr[]= {9,8,7,6,5,4,3,2,1,0};
	static int visited[]= {0,0,0,0,0,0,0,0,0,0};
	public static void main(String[] args) {
		dfs(0);
	}
	public static void dfs(int offset) {
		if(offset==10) {
			long a=01;
			for(int i=0;i<10;i++)
			{
				a=a*10+arr[i];
			}
			long sq=(long)Math.sqrt(a);
			if(sq*sq==a)
			{
				System.out.println(a);
				return;
			}
		}
		for(int i=0;i<10;i++)
		{
			if(visited[i]==0)
			{
				visited[i]=1;
				arr[offset]=i;
				dfs(offset+1);
				visited[i]=0;
			}
		}
	}
	

2. Life Game
Conway Life Game is a cellular automaton invented by British mathematician John Horton Conway in 1970.
This game is played on an infinite 2D grid.
At the beginning, each small square inhabited a living or dead cell.
The state of each cell at the next moment is determined by the cell states of the eight cells around it.
Specifically:

  1. When the current cell is in a viable state, when there are less than 2 (excluding 2) viable cells around, the cell becomes dead. (The number of simulated lives is scarce)
  2. When the current cell is in a viable state, when there are 2 or 3 viable cells around, the cell remains as it is.
  3. When the current cell is in a living state, when there are more than three living cells around, the cell becomes a dead state. (Too many simulated lives)
  4. When the current cell is in a dead state, when there are 3 living cells around, the cell becomes a living state. (Simulation reproduction) After
    all the cells of the current generation are processed by the above rules at the same time, the next generation cell map can be obtained. Continue to process the cell map of this generation according to the rules, and you can get the cell map of the next generation, and start again and again.
    For example, assume initially: (X represents the living cell, on behalf of dead cells.)
    ...
    ...
    the .XXX.
    ...

The next generation will become:

...
... the X-...
... the X-...
... the X-...
...
some interesting patterns occur in Conway's Game of Life. For example, a stable pattern:

.XX.
.XX.

And a looping pattern:
………
.XX… .XX… .XX…
.XX… .X… .XX
…… XX .- >… X .->… XX.
… XX.… XX.… XX.
………

In this problem we have to discuss is a very special model, known as the "Gosper Glider Gun":
...
... the X-...
... XX ...
. ... ... XX XX XX ...
. ... the X-XX ... XX ... ... the X-
.XX ... the X-... X ... XX ...
.XX ... X ... X.XX ... XX ...
… X ... X ... X ...
… X ... X ...
… XX ...

Assuming the above initial state is generation 0, how many living cells are there in the 1000000000 (billion) generation?

Note: We assume that the cell machine is deduced on an infinite 2D grid, not just the space drawn in the title.
Of course, for distant locations, the initial state is all dead cells.
Note: What needs to be submitted is an integer, do not fill in the extra content.
(It's hard to look at it and gave up)

Published 44 original articles · Likes2 · Visits 540

Guess you like

Origin blog.csdn.net/qq_43699776/article/details/105292529