Question:Calculate the number of numbers with a prime number of 2, 3, and 5, including 1.Analysis:As long as you want to obtain 1,500th, you can use the table-making method to obtain all the first 1500 numbers,Because each ugly number can be
Analysis:
Extended EuclideanAlgorithm, Ax + by = gcd (a, B), if gcd (a, B )! = 1, output-1. Otherwise, use the Extended Euclidean algorithm.
The minimum values of X and Y are enough.
If 0 exists, if 1 exists, 1 is output; otherwise,-1 is
/*
Question:
Find the minimum ring and output path in the graph.
Analysis:
You can use enumeration to delete an edge to see if it can be moved from one point to another.
If the length of the deleted edge is smaller than the current
/*
Question:
In ice hockey games, each time you have to move the corresponding steps to the left and right. Only when you encounter a rock will it stop before the rock. Otherwise
It is necessary to go out of bounds. Ask how to move ice
# Include # Include # Include Using namespace STD;# Define x 1000005Char s [X], p [x];Int next [X], len1, len2;Void shift () // computing the moving Template{Int I, j =-1;Next [0] =-1;For (I = 1; I {While (J! =-1 & S [J + 1]! = S [I])J = next [J];If
Question:From A to B, B to a will work.Analysis:Initialize A [I] = I, then merge X, Y, and submit a [X], a [Y]. Final judge whether a [I] = I
# Include # include # include # include # include # include # include # include # include #
Basic BFS questions, but found that I have not done a search question for a long time, this question is very uncomfortable, especially the processing of the direction constant, completely copied from others.
Code:
Const NX: array [0 .. 2, 1 .. 4]
Analysis: simply use DFS. Nothing. The search time starting from 1000 is +, and the search time starting from N and N is 16 Ms. Gap. So the best way is to search randomly.
The other two soduku on poj are not easy to search for. Many of the data of
Simple and hard to write:
For I: = 0 to n do f [I, 0]: = 0; for I: = 1 to n do begin for J: = 1 to a [I]. s-1 do f [I, j]: = max (F [I-1, J], F [I, J-1]); For J: = A [I]. s to a [I]. S + A [I]. l-1 do begin if j> L then break; F [I, j]: = max (F
Analysis: the classic queue application achieves the maximum and minimum search of N.
VaR A, Q: array [0 .. 1000000] of longint; I, j, Head, tail, n, m: longint; begin readln (n, m); for I: = 1 to n do read (A [I]); Head: = 1; tail: = 1; Q [1]: = 1;
Description
Given a sequence with a length of N, all numbers are 0 at the beginning. There are two operations in the future:1: For operation 1, read two numbers x and y, which indicates that the numbers in the
Idea reference self-http://blog.csdn.net/yylxid/article/details/8601075
Question: Given the circumference n of a triangle, ask the number of triangles that can be formed. If the three sides are unequal, add one
Analysis: assume that the three
Calculate the shortest path of each vertex, and then calculate the DFS count based on the shortest path of each vertex.
View code
# Include # Include Using Namespace STD; Const Int N = 1001 ; Int G [N] [N], n, m, DIST [N]; Int ANS, DP [N];
Given a directed graph and a starting point of N + 1 points, find the shortest path that passes through the remaining N points and return to the starting point .. (N
Analysis: when we see such a small amount of data, we will know that it is not a
Chinese questions.
But I cannot think of and query the set.
The paths in the question are sorted by speed. In this way, if all the paths from route I to route J can connect I to route J, there is a road, and the comfort of this road is the
/* This is a good question .. DFS .. Add parity pruning ..DFS will not talk about it .. Let's talk about parity pruning ,,You can think of map as follows:0 1 0 1 0 11 0 1 0 1 00 1 0 1 0 11 0 1 0 1 00 1 0 1 0 1Take a step from a grid with 0 to a grid
Tangled in cables
You are the owner of smallcableco and have purchased the franchise rights for a small town. unfortunately, you lack enough funds to start your business properly and are relying on parts you have found in an old warehouse you
Question:Returns the largest common subsequence (LCS)Analysis:It's depressing to use DP. There is a space. I used scanf to read wa, And I used gets to read.The state transfer equation is DP [I] [J] = DP [I-1] [J-1] + 1, S1 [I] = S2 [J]= Max {DP [I-1]
View Code
# Include # include # include using namespace std; const int maxn = 105; int equ, var; // There are equ equations, var variable. The number of rows in the augmented array is equ, ranging from 0 to equ-1, and the number of columns is
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service