-
給定n個整數a , a , ,an 1 2 組成的序列。序列中元素i a 的符號定義為:
ï î
ï í
ì
- <
=
>
=
1 0
0 0
1 0
sgn( )
i
i
i
i
a
a
a
a
符號平衡問題要求給定序列的最長符號平衡段的長度L,即:
þ ý ü
î í ì
= + - = å
=
£ £ £
max 1| sgn( ) 0
1
j
k i
i j n k
L j i a 。
例如,當n=10,相應序列為:1,1,-1,-2,0,1,3,-1,2,-1 時,L=9。
標簽:
iuml
61516
icirc
序列
上傳時間:
2015-10-28
上傳用戶:xaijhqx
-
給定n 個整數a ,a , ,an 1 2 組成的序列, a n i | |£ ,1 £ i £ n。如果對于i £ j ,有
0 = å
=
j
k i
k a ,則稱序列區間i i j a , a , , a +1 為一個零和區間,相應的區間長度為j-i+1。
標簽:
61516
an
整數
序列
上傳時間:
2015-07-23
上傳用戶:zhangzhenyu
-
給定n 個整數a ,a , ,an 1 2 組成的序列, a n i | |£ ,1 £ i £ n。如果對于i £ j ,有
0 = å
=
j
k i
k a ,則稱序列區間i i j a , a , , a +1 為一個零和區間,相應的區間長度為j-i+1。
標簽:
61516
an
整數
序列
上傳時間:
2013-12-21
上傳用戶:偷心的海盜
-
本題的算法中涉及的三個函數:
double bbp(int n,int k,int l) 其中n為十六進制位第n位,k取值范圍為0到n+7,用來計算16nS1,16nS2,16nS3,16nS4小數部分的每一項。返回每一項的小數部分。
void pi(int m,int n,int p[]) 計算從n位開始的連續m位的十六進制數字。其中p為存儲十六進制數字的數組。
void div(int p[])
void add(int a[],int b[]) 這兩個函數都是為最后把十六進制數字轉換為十進制數字服務的。
最后把1000個數字分別存儲在整型數組r[]中,輸出就是按順序輸出該數組。
標簽:
int
double
bbp
算法
上傳時間:
2014-01-05
上傳用戶:xcy122677
-
Ex4-22 單射函數問題
« 問題描述:
設函數f將點集S = {0,1, , n -1}映射為f (S) = { f (i) | iÎ S} Í S 。單射函數問題要
從S中選取最大子集X Í S 使f (X )是單射函數。
例如,當n=7, f (S) = {1,0,0,2,2,3,6} Í S 時, X = {0,1,6} Í S 是所求的最大子集。
« 編程任務:
對于給定的點集S = {0,1, , n -1}上函數f,試用抽象數據類型隊列,設計一個O(n)時
間算法,計算f的最大單射子集。
« 數據輸入:
由文件input.txt 提供輸入數據。文件的第1 行有1 個正整數n,表示給定的點集
S = {0,1, , n -1}。第2 行是f (i)的值,0 £ i < n。
« 結果輸出:
程序運行結束時,將計算出的f的最大單射子集的大小輸出到output.txt中。
輸入文件示例 輸出文件示例
input.txt
7
1 0 0 2 2 3 6
output.txt
3
標簽:
Iacute
61516
laquo
Icirc
上傳時間:
2016-05-28
上傳用戶:tyler
-
求標準偏差
> function c=myfunction(x)
> [m,n]=size(x)
> t=0
> for i=1:numel(x)
> t=t+x(i)*x(i)
> end
> c=sqrt(t/(m*n-1))
function c=myfunction(x)
[m,n]=size(x)
t=0
for i=1:m
for j=1:n
t=t+x(i,j)*x(i,j)
end
end
c=sqrt(t/(m*n-1
標簽:
gt
myfunction
function
numel
上傳時間:
2014-01-15
上傳用戶:hongmo
-
求標準偏差
> function c=myfunction(x)
> [m,n]=size(x)
> t=0
> for i=1:numel(x)
> t=t+x(i)*x(i)
> end
> c=sqrt(t/(m*n-1))
function c=myfunction(x)
[m,n]=size(x)
t=0
for i=1:m
for j=1:n
t=t+x(i,j)*x(i,j)
end
end
c=sqrt(t/(m*n-1
標簽:
gt
myfunction
function
numel
上傳時間:
2013-12-26
上傳用戶:dreamboy36
-
求標準偏差
> function c=myfunction(x)
> [m,n]=size(x)
> t=0
> for i=1:numel(x)
> t=t+x(i)*x(i)
> end
> c=sqrt(t/(m*n-1))
function c=myfunction(x)
[m,n]=size(x)
t=0
for i=1:m
for j=1:n
t=t+x(i,j)*x(i,j)
end
end
c=sqrt(t/(m*n-1
標簽:
gt
myfunction
function
numel
上傳時間:
2016-06-28
上傳用戶:change0329
-
求標準偏差
> function c=myfunction(x)
> [m,n]=size(x)
> t=0
> for i=1:numel(x)
> t=t+x(i)*x(i)
> end
> c=sqrt(t/(m*n-1))
function c=myfunction(x)
[m,n]=size(x)
t=0
for i=1:m
for j=1:n
t=t+x(i,j)*x(i,j)
end
end
c=sqrt(t/(m*n-1
標簽:
gt
myfunction
function
numel
上傳時間:
2014-09-03
上傳用戶:jjj0202
-
OTSU Gray-level image segmentation using Otsu s method.
Iseg = OTSU(I,n) computes a segmented image (Iseg) containing n classes
by means of Otsu s n-thresholding method (Otsu N, A Threshold Selection
Method from Gray-Level Histograms, IEEE Trans. Syst. Man Cybern.
9:62-66 1979). Thresholds are computed to maximize a separability
criterion of the resultant classes in gray levels.
OTSU(I) is equivalent to OTSU(I,2). By default, n=2 and the
corresponding Iseg is therefore a binary image. The pixel values for
Iseg are [0 1] if n=2, [0 0.5 1] if n=3, [0 0.333 0.666 1] if n=4, ...
[Iseg,sep] = OTSU(I,n) returns the value (sep) of the separability
criterion within the range [0 1]. Zero is obtained only with images
having less than n gray level, whereas one (optimal value) is obtained
only with n-valued images.
標簽:
OTSU
segmentation
Gray-level
segmented
上傳時間:
2017-04-24
上傳用戶:yuzsu