10970 pieces of chocolate (memory recursion or regularity)

// Recursive memory # include # include using namespace STD; int d [305] [305]; int F (int I, Int J) {If (d [I] [J]! =-1) return d [I] [J]; if (I = 1) return d [I] [J] = J-1; If (j = 1) return d [I] [J] = I-1; if (I % 2 = 0) return d [I] [J] = 2 *

Uva11905 connection count (Greedy)

# Include # include # include # include using namespace STD; struct Cha {string a;} d [55]; int CMP (Cha A, Cha B) // It cannot be compared directly by comparing functions with strings, for example, 563,56 {string C, D; C =. A + B. a; D = B. A +.

Shortest Path Dijkstra Algorithm

# Include # include # define num 100 # define maxint 10000 void Dijkstra (int n, int V, int Dist [], int Prev [], int C [] [num]) {int I, j; bool s [num]; for (I = 1; I maxint) Prev [I] = 0; else Prev [I] = V;} Dist [v] = 0; s [v] = true; for (I =

Ultraviolet A 10780 again Prime? No time.

Unique decomposition of prime numbers and the nature of factorial: n! Number of X contained in # Include # include using namespace STD; int getsum (int n, int X) {int ans = 0; while (N) {ans + = N/X; N/= x;} return ans;} int main (INT argc, char *

Max stream poj1273

// Edmonds_karp # include # include using namespace STD; const int n = 210; // maximum number of vertices const int INF = 0x7fffffff; // infinity int n, m, map [N] [N], path [N], flow [N], start, end; // n is the vertex, M is the edge, map is the

Nyist 284 & poj 2312 tank war (deformation BFS)

This is a prototype of the tank war. It is a variant of the maze. Given a map of mxn, there are ordinary bricks B, bricks S, and river R on the map, open space E, and a treasure location T, and your location y, find the minimum number of steps to

Ultraviolet A 10047 unicycles (BFS)

Direct BFs. Note that there is a blank line between the two data. # Include # include # include using namespace STD; int n, m, BZ [30] [30] [6] [5]; char A [30] [30]; struct point {int X, Y, C, Se, time;} e; int H [4] [2] = {-1, 0, 0, 1, 0, 0,

Ultraviolet A 10795 a different task

# Include # include using namespace STD; long F (INT temp [], int I, int aim) {If (! I) Return 0;/* I just on the aim I don't need to move, otherwise I first move the I-1 above the transit, moving I to aim (1 time), finally moving all I-1 to aim :(

Nyist 305 expression evaluate (recursion)

Click to open the question link # Include # include using namespace STD; int I; string s; int F () {I ++; int x = 0; while (S [I] = ')' | s [I] = ',') & I = '0' & S [I] = '0' & S [I + 1] T; while (t --) {CIN> S; I =-1; cout  

Ultraviolet A 10382 (nyist 12 sprinkler 2)

# Include using namespace STD; # include # include struct point {float L, R;} p [10005]; int main (INT argc, char * argv []) {float W, H, S, X1, X, R, X2; int I, n, ans; while (scanf ("% d % F", & N, & W, & H )! = EOF) // nyist has a number of

Ultraviolet A 1350 & la 3357 pinary (recurrence)

Click to open the question link The simulation of this question is:Fibonacci Series, You can know the number of digits. How to generate this sequence is a problem? The following are others' ideas: Detailed description:Ans [1] = 1, ANS [2] = 1,

Poj 1258 prim Minimum Spanning Tree

# Include using namespace STD; int A [105] [105], B [105], n; int prim (int ii) {int I, J, K, min, ANS = 0, T; for (I = 0; I B [J] & B [J]! =-1) min = B [J], t = J; ans + = min; B [T] =-1; for (j = 0; j N) {for (I = 0; I A [I] [J]; cout  

High-Precision addition template (string type, char)

Method 1: string class void add(string &s1,string s2)//s1=s1+s2 {int i,j,sum=0;if(s1.length()=0;i--,j--) { sum+=s1[i]-'0'; if(j>=0) sum+=s2[j]-'0'; s1[i]=sum%10+'0'; sum/=10; } if(sum) s1='1'+s1;} Method 2: string

Difficulties of nkpc1 Lucy

For the given F (n) WHEN n> = 50025002, F (n) = N-5; when n If recursion is used, stack overflow will occur !!! Recursive loops: F (m, n) indicates that parameter n is nested with m layer F, for example F (3, n) = f (N ))) F (1, N) = f (N) F (

11100 (Greedy)

# Include # include using namespace STD; int main (INT argc, char * argv []) {int N, I, j, a [10005], ANS, temp; while (CIN> N & N) {for (I = 0; I A [I]; sort (A, A + n); For (ANS = I = temp = 1; I = ans) ans = temp; temp = 1 ;}} cout

Nyist 202 red/black tree (sequential traversal of Binary Trees)

Rotation does not affect the central order traversal. You can directly output the results in the central order. # Include # include using namespace STD; int N; struct Shu {int left, rict ;} Shu [1000005]; int Zhong (int id) {If (ID> = 0) {Zhong

Poj 2305 (in hexadecimal notation, modulo of large numbers)

Enter a base B, and then input two big integers x and y based on the base B to calculate the base B result of X % Y. Http: // 162.105.81.212/judgeonline/problem? Id = 2305 Function:String ST = integer. tostring (Num, base); // convert num into base (

Nyist 737 merge adjacent stones

Http://acm.nyist.net/JudgeOnline/problem.php? PID = 1, 737 Dynamic Planning state equation: DP [I] [J] = d [I] [k] + dp [k + 1] [J] + (sum [k]-sum [I-1]) + (sum [J]-sum [k]) Boundary: 0 If (I = J) DP [I] [J] = 0; Sum [I] = sum of the first I

Ultraviolet A 11552 fewest flops (3D Dynamic Planning)

DP [l] [I] [J] indicates the minimum number of blocks in the L group starting with the I letter group and ending with the J letter Group N = strlen (s)/K The DP [l] [I] [J] values are divided into two situations: 1. the header I is found in the

Nyist 740 "Hyun dancer" ST (Dynamic Planning)

DP [I] [J] [k]: represents the position of the second foot after the I step. First fix the position of one foot J. After the I step on, status: DP [I] [J] [A [I] or DP [I] [A [I] [J], where a [I] indicates the I-th input element, there is a state

Total Pages: 64722 1 .... 56940 56941 56942 56943 56944 .... 64722 Go to: GO

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.