When at both ends: a total of n * (n-1) combinations, satisfying the condition of having, the calculation is available, counter = n * (n-1)/2.Other locations: A total of n * (n-1) * (n-2) combinations, to meet the conditions, the use of squares and formulas can be obtained counter = n * (n-1) * (n-2)/3.#include using namespacestd;intMain () {intN; while(~SCANF ("%d",N)) {DoubleAns =0.0, C; for(intI=1; i) {scanf ("%LF", c); if(i = =1|| i = = N) ans + = c/2.0; ElseAns + = c/3.0; } printf ("%lf\n
First, you know what Euler's function is!!!The Euler function is the number of numbers less than N and N coprime (greatest common divisor is 1);Then, you need to think aboutIf n is the K power of prime number p,, because other than the multiples of p, the other numbers are coprime with N.Can getIf the code:intPhiintN) { intI,rea=N; for(i=2; i*i) { if(n%i==0) {rea=rea-rea/i; while(n%i==0) n/=i; } } if(n>1) Rea=rea-rea/N; returnRea;}Pan: Euler's function has many more importan
ProveIf: function y=ax^2+2bx+c to any x >=0 y>=0;function image above all x-axis, so two-time equation discriminant b^2-4acIE (2b) ^2Note: The x0-b/a in G (x0) A (X0-B/1) ^2 above should be represented as (x0+b/a); Reference discriminant:Http://baike.baidu.com/link?url=pwwiWoBpl4yNww_tA7mbm3tcZsIYGuw40GScqkgYiUUsykFWFXsWvLzGsgFtE7nrnqCkox0cgzUhM3rCK8cjTqNote in the tutorial (P338 Schwarz expression proof) Ax^2+bx+c should be written ax^2+2bx+cProof of
).Order: A = 2 (cos (2Π/17) + cos (4Π/17) + cos (8Π/17) + cos (16Π/17)) ①A1 = 2 (cos (6Π/17) + cos (10Π/17) + cos (12Π/17) + cos (14Π/17)) ②Through the and differential product, induction formula, we will get a + a1 =-1, a*a1 =-4, can be restored by the establishment of a two-time equation, using the above theorem, can be a length of a, A1 line.Order: b = 2 (cos (2Π/17) + cos (8Π/17)) ③B1 = 2 (cos (4Π/17) + cos (16Π/17)) ④Through and the difference product, induces the formula, we will obtain B
Use the document encryption software to encrypt the source code, and realize the source code to protect against leaks. The current practice is poor, the following failure cases can be verified:BYD, Yulong Communications, cool, Chinese communications and so on (are the same company do, the name will not say, ask users to know, Beijing. )1) card, slow, blue screen, damaged data;2) The existence of loopholes, security is not high;3) The technical controversy continues;Source code leak
conclusion.
The following is a proof of concept:
Assume that p is a prime number. The number of decimal places in 1/p is X, and 1/P can be expressed as X/999... 9. The denominator has x 9 in total,
For example:1/3 = 0. 33..., loop decimal point = 3, loop decimal point = 1, then 1/3 = 3/91/7 = 0. 142857142857..., the number of decimal places in the loop = 142857, and the number of decimal places in the loop = 6, then 1/7 = 142857/9999991/37 = 0.
Euclid rule: If x and y are both positive integers and x>=y, then gcd (x, y) =gcdAssuming that x and Y are gcd A, then there must beX=a*n1Y=a*n2 (GCD (n1,n2) =1)Then we begX mod y=>A*N1 MoD a*n2Make x mod y=m, then it must satisfyX=n3*y+m=>a*n1=n3*a*n2+m=>m=a* (N1-N2*N3)Then gcd (x mod y,y) becomes gcd (A * (N1-N2*N3), a*n2),If GCD (N1-N2*N3,N2) is not equal to 1, then the equation is not trueSuppose gcd (n1-n2*n3,n2) =k (k>1),Then makeN1-n2*n3=n4*kN2=n5*kAnd thenN1=n2*n3+n4*k=n5*k*n3+n4*k=k (N3
Often can be seen in the literature 2d-fft can be achieved by two 1d-fft, today I use MATLAB to prove that, indeed. The code for MATLAB is as followsClear All;clc;f=ones (256,256); center_loc = size (f); rd = 2;f (Round (Center_loc (1)/2)-rd:round (Center_loc (1)/2) +rd, Round (Center_loc (2)/2)-rd:round (Center_loc (2)/2) +rd) = 0;figure (1); Imshow (f); f2=fft2 (f); f3= (ABS (F2)); figure (2); Imshow (F3); Tmp=zeros (Center_loc (1), Center_loc (2)),%-the first 1d-fft, for each rowfor i= 1:cent
Q: If the data d is linearly divided, how does the PLA guarantee that the optimal solution can be obtained at last.Idea: Suppose $w_f$ can split data D, $w _{t+1}$ after updating $w_{t+1}=w_t + y_{n (t)}x_{n (t)}$, closer to $w_f$Two vectors closer, then there are $z=\frac{w_f^tw_t}{| | w_f| | | | w_t| |} $ biggerwhere $w_f^tw_t=w_f^tw_{t-1}+w_f^ty_{n (i)}x_{n (i)}=w_f^tw_0+w_f^t\sum_i^t y_{n (i)}x_{n (i)}$Make $w_0=0$, then $w_f^tw_t \geq 0+t min (w_f^ty_{n (i)}x_{n (i)}) $Similarly, because on
RMB Exchange Integration Method for 10.3 dual points
In the calculation of the fixed points of a one-dimensional function, we often change the yuan to simplify the purpose. Of course, the dual points also have the problem of changing the Yuan points.
First, let's review a fact discussed earlier.
Let's change the meta function as a ing from the defined domain. The point's point is, the point X's point is, remember
,
The length from the line segment to the point is called the average scaling rate
element is found to be greater than K, you can know that there are no equal elements in the other array (it can be proved by the ordered nature of the array), so you can skip the K element. If they are equal, they are found. You can jump from the two arrays to the next element and continue searching. Based on the above ideas, it is not difficult to understand the backbone of the algorithm. Here, the element K is not fixed. Because the two arrays are completely symmetric, the relationship is mu
HDU 5187 zhx's contest (explosion proof _ int64), hdu _ int64
Problem DescriptionAs one of the most powerful brushes, zhx is required to give his juniors
N
Problems.
Zhx thinks
Ith
Problem's difficulty is
I
. He wants to arrange these problems in a beautiful way.
Zhx defines a sequence
{Ai}
Beautiful if there is
I
That matches two rules below:
1:
A1.. ai
Are monotone decreasing or monotone increasing.
2:
Ai ..
Are monotone decreas
The Fibonacci series can be derived from many applications. We know that the time complexity of the Fibonacci series is exponential. Now let's roughly prove it:
Fibonacci SeriesRecurrence:
F (n) = f (n-1) + f (n-2)
F (1) = F (2) = 1
It is roughly proved that decision_tree can be used. For more intuitive purposes, I reference another constant function f (x) = 0; X = 1, 2, 4, 5 ,............
SoFibonacci SeriesRecursive deformation is as follows:
F (n) = f (n-1) + f (n-2)+ F (N)
F (1) = F (2
Label: style blog HTTP color Io OS AR for SP
It is said that the title length can attract people's attention
We all use SPAF... Are you not afraid of getting stuck?
The improved heap optimization Dijkstra is coming soon !!! This Board is both nice-looking and practical.
1 /************************************************************** 2 Problem: 1681 3 User: rausen 4 Language: C++ 5 Result: Accepted 6 Time:8 ms 7 Memory:872 kb 8 *****************************************
2ban.pid-xroot 1558 0.0 0.1 103248 868 pts/0 s+ 06:37 0:00 grep fail2banNext you can see that there are fail2ban processes that we test.[[Email protected]129-slave fail2ban-0.8. -]#SSH 192.168.182.129The authenticity of host'192.168.182.129 (192.168.182.129)'Can't be established.RSA Key fingerprint is in: -: the: 7b:a0: to: About: AF: -: the: 0e:ed: the: AD:CF: the. Is you sure want to continue connecting (yes/no)?Yeswarning:permanently added'192.168.182.129'(RSA) to the list of known hosts. [E
3 5
63923 99999
Sample Output
3 5 Good Choice
Bad Choice
63923 99999 Good Choice
The first can be directly calculated by brute force:
/*0.082s*/
#include
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/
Using the above code, you can find that when mod=20, only 1,3,7,9,11,13,17,19,... is a good choice, and these numbers are 20 coprime.
So we guess: when gcd (Step,mod)!=1, this is not a good choice.
Gas Station
There are N gas stations along a circular route, where the amount of gas in station I is gas[i].
You are have a car with the unlimited gas tank and it costs cost[i] of the gas to the travel from station I to its next station (I+1). You begin the journey with a empty tank at one of the gas stations.
Return to the starting gas station ' s index if you can travel around the circuit once, otherwise return-1.
Note:The solution is guaranteed unique.
This problem is also very troublesome.
operation of backtracking
The complexity of the algorithm proves: because the merge sort algorithm is binary, so the division naturally has the following proof:
T (n) =2t (N/2) +f (n) Note that the consideration of f (n) here is from the back forward, since the advantages of merge sorting are similar to the subsequent traversal of binary trees, f (n) is said to represent the merging operation of the recursive tree of each layer, so f (n) is an O (n)
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.