Daily Punch-In (1/2)
Portal: Click to open link
Main topic:
Look for an integer that is a multiple of n (1
Ideas:
First, n is a number not less than 1, assuming the final number is m, then M is necessarily the first bit is 1.
After determining the first, there are two cases: 11 and 10, this time with a bfs/dfs can be solved, for the sake of insurance write BFS. In each case use m%n, if the result is
Topic links
Test instructions: Your task is to help J out of a maze of fires spreading. J can move up or down in four directions per minute, and all the burning squares will spread around. There are some obstacles in the maze, J and fire can not enter. When J went to the boundary lattice of a maze, we thought he had gone out of the maze.
Idea: This is a problem above the white, in fact, as long as each lattice what time on fire to deal with it. Two times B
It's a lot more fire than the general BFS.
So, first, make a fire. BFS pre-processing each lattice ignition time
Lazy to open the number of groups and then wrong for half a day
#include
Test Instructions:N (1e3), K (1e6), A1~ak (1E3). Select the minimum number of AI (can be repeated) T, so that sum (AI)/t/1000==n/1000 set up.
The following:K (1e6), A1~ak (1E3)--and the number is only 1e3.
SUM (AI)/t/1000==n/1000--sum (AI) ==t*n---sum (ai-n) ==0
t
Solution One: BFS
If there is a set of solutions b1+b2+...+bt==0, then we can change the position of the array elements so that all prefixes and ranges are [ -1000,1000].
Then we can use 0
Topic Connection: http://poj.org/problem?id=3126
Test instructions: Given two prime numbers, find the shortest prime number path between the two.
This problem with a single bfs is enough, but, or practice the double BFS.
Code:
#include
Title Link: http://uva.onlinejudge.org/external/116/11624.pdf
Test instructions: Given a maze and some ignition points, the fire will constantly want to spread around, seeking a shortest path to escape the maze.
Idea: First use BFS to find out the fire spread to each point of the shortest time, you can set the # time to 0, '. ' The fire can't be set to OO (it should be noted here, WA once). The following is the conventional
.
The real vertices count is *
Searchgraph.java
Import java.util.ArrayList;
Import Java.util.Iterator;
Import java.util.LinkedList;
Import java.util.List;
Import Java.util.Queue;
Import Java.util.Stack; public class Searchgraph {public static list
Main.java
Import java.util.List;
public class Main {public
static Graph createtestgraph () {
graph G = new Graph ();
G.addvertex ("A");
G.addvertex ("B");
G.addvertex ("C");
G.addvertex ("D");
G.addvertex ("E");
G.addv
Article Title: BFS introduction, a required course for Linux to speed up. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
As in the past, we are still compiling the new Linux kernel, a required course for accelerating the Linux system. The encounter with Linux kernel BFS
Summary: we can search down at the same depth when the initial state is about to reach the termination state, which covers a wider range and is very useful when the depth of the solution is small.
Tips and notes:
BFS has many tips. Let me list them one by one:
Note:: When saving BFS status, you must try to reduce the status and store only valid information for BFs
In fact, it is added a time limit of the detonation, anyway n,m to a very small, directly recorded 3-dimensional state, then very casual.#include HDU 1072 Nightmare BFS
contains m characters. The characters may:'. ' Denotes an empty place and all can walk on.' X ' denotes a wall, only people can ' t walk on.' M ' denotes little Erriyue' G ' denotes the girl friend.' Z ' denotes the ghosts.It is guaranteed that would contain exactly one letter M, one letter G and one letters Z.Outputoutput A single integer s on one line, denotes Erriyue and his girlfriend would meet in the minimum time s if they CA N meet successfully, or output-1 denotes they failed to meet.Sa
' t know some very cheap software gurus.
-in fact, I do. You are there are this programming contest going ... Help the prime minister the cheapest prime path between any two given four-digit primes! The digit must be nonzero, of course. Here are a solution in the case above.
1033
1733
3733
3739
3779
8779
8179
The cost of this solution is 6 pounds. Note that the digit 1 which got pasted the "in" Step 2 can is reused in the last Step–a new 1 must to be purchased.
Input
One line with a positive n
Description
Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains on Ly the digits 0 and 1. You could assume that n are not greater than and there are a corresponding m containing no more than decimal digits.
Input
The input file may contain multiple test cases. Each line contains a value of n (1
Output
For each value of "N in" the input print a line containing the corresponding value of M. The decimal representation of M must n
pressure. With the first box of the binary number of the first I, 1 for the box is pressed down, 0 for the box has not been pressed down. In the end we just need to find 1 of the states that appear most often.
The first reaction is to think in the direction of DP, enumerate each state, and finally find the maximum number of box that is pressed down in all feasible states. In this case, however, the total state number is 1
A further refinement is the pretreatment of the scheme (very shameless to
is guaranteed to am no less than 3 and no more than 30.
If Some deadlines can is fulfilled, please output "-1" (which means the Super Doge would say "wow!" So slow! Such delay! Much anger! . . . ", but you don't need to output it), else output the minimum sum of all arrival time to each Doge Planet.
Sample Input
4
0 3 8 6 4 0 7 4 7 5 0 2 6 9 3 0 8 4 0 2 3 3 2 0 3 3 2 3 0 3 2 3 3 0 2
3 3Sample Output
1
The main idea of the topic is that a matrix of n multiplied by N is D,DXY to represent t
Title: Fzu 2150 Fire Game
Give a m*n figure, ' # ' means lawn, '. ' Show the open space, and then you can choose to fire in any of the two lawn lattices, the fire every 1 s will spread to the surrounding four lattice, ask those two points to make burning all the lawn spend the least time.
Analysis: This topic is a bit difficult to think about, but given the small data range, we can violently enumerate the points where any lawn is located, and then press the two points into the queue to
) {
Lnode *temp = result->top->next;
if (temp!= NULL) {
result->top->next = temp->next;
}
Temp->next = NULL;
return temp;
}
We'll give you the definition of the main function.
int main (void) {/* MAX's value is 5 * defines a two-dimensional array * Input the value of the maze and initializes a stack/int maze[max][max];
int I, J;
for (i = 0;i
Finally when we output the stack path, we are back from the end to the beginning of the stack output, at this tim
Original title URL: http://nanti.jisuanke.com/t/11064
What is the river, for the big nails in the chess world, the lake is a matrix, his goal is to ride a horse in the rivers and lakes, from his position to go to the end.
Of course, the big nailed horse also obeys the Chinese chess "The horse Goes Day" the rule, and in the matrix, there will be some obstacles, the horse can not jump to the obstacles, if the big nails in front of the horse is a barrier, that is, "horse legs", then he will not be
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.