topic:
1, calculate
(Granted method)
Problem Description
For a given N, it is required to calculate in the o (n) step.
At the same time, it analyzes the time complexity and spatial complexity of the program.
Enter: N,
Output:
thought:
1. Realize the amount of calculation with a common algorithm
Magnitude;
2. Implementation of the algorithm for the O (N) level
Different implementation of grants:
Utilize the function:
F (n) =
program
// ******************************************************** ************************************** For a given N, required in O (N The 2 N power of 2 2 is calculated, and the time complexity and spatial complexity of the program are analyzed. // Use the granted method // Author: dongkaiying // use the commitness, we can find, the 'n' can only be the // region Lower Than 9; So Weme Must Find A better method to reduce the complexity of the "fenzhifa" we caled.//************************************* *********************************************************** ********* # include
// USE the DIGUI METHOD; DOUBLE FENZHI_M (INT N) {IF (n == 1) Return 4; Else Return Fenzhi_m (N-1) * fenzhi_m (N-1);}