-
RSA算法 :首先, 找出三個數(shù), p, q, r, 其中 p, q 是兩個相異的質(zhì)數(shù), r 是與 (p-1)(q-1) 互質(zhì)的數(shù)...... p, q, r 這三個數(shù)便是 person_key,接著, 找出 m, 使得 r^m == 1 mod (p-1)(q-1)..... 這個 m 一定存在, 因?yàn)?r 與 (p-1)(q-1) 互質(zhì), 用輾轉(zhuǎn)相除法就可以得到了..... 再來, 計算 n = pq....... m, n 這兩個數(shù)便是 public_key ,編碼過程是, 若資料為 a, 將其看成是一個大整數(shù), 假設(shè) a < n.... 如果 a >= n 的話, 就將 a 表成 s 進(jìn)位 (s
標(biāo)簽:
person_key
RSA
算法
上傳時間:
2013-12-14
上傳用戶:zhuyibin
-
The government of a small but important country has decided that the alphabet needs to be streamlined and reordered. Uppercase letters will be eliminated. They will issue a royal decree in the form of a String of B and A characters. The first character in the decree specifies whether a must come ( B )Before b in the new alphabet or ( A )After b . The second character determines the relative placement of b and c , etc. So, for example, "BAA" means that a must come Before b , b must come After c , and c must come After d .
Any letters beyond these requirements are to be excluded, so if the decree specifies k comparisons then the new alphabet will contain the first k+1 lowercase letters of the current alphabet.
Create a class Alphabet that contains the method choices that takes the decree as input and returns the number of possible new alphabets that conform to the decree. If more than 1,000,000,000 are possible, return -1.
Definition
標(biāo)簽:
government
streamline
important
alphabet
上傳時間:
2015-06-09
上傳用戶:weixiao99
-
上下文無關(guān)文法(Context-Free Grammar, CFG)是一個4元組G=(V, T, S, P),其中,V和T是不相交的有限集,S∈V,P是一組有限的產(chǎn)生式規(guī)則集,形如A→α,其中A∈V,且α∈(V∪T)*。V的元素稱為非終結(jié)符,T的元素稱為終結(jié)符,S是一個特殊的非終結(jié)符,稱為文法開始符。
設(shè)G=(V, T, S, P)是一個CFG,則G產(chǎn)生的語言是所有可由G產(chǎn)生的字符串組成的集合,即L(G)={x∈T* | Sx}。一個語言L是上下文無關(guān)語言(Context-Free Language, CFL),當(dāng)且僅當(dāng)存在一個CFG G,使得L=L(G)。 *⇒
例如,設(shè)文法G:S→AB
A→aA|a
B→bB|b
則L(G)={a^nb^m | n,m>=1}
其中非終結(jié)符都是大寫字母,開始符都是S,終結(jié)符都是小寫字母。
標(biāo)簽:
Context-Free
Grammar
CFG
上傳時間:
2013-12-10
上傳用戶:gaojiao1999
-
We have a group of N items (represented by integers from 1 to N), and we know that there is some total order defined for these items. You may assume that no two elements will be equal (for all a, b: a<b or b<a). However, it is expensive to compare two items. Your task is to make a number of comparisons, and then output the sorted order. The cost of determining if a < b is given by the bth integer of element a of costs (space delimited), which is the same as the ath integer of element b. Naturally, you will be judged on the total cost of the comparisons you make before outputting the sorted order. If your order is incorrect, you will receive a 0. Otherwise, your score will be opt/cost, where opt is the best cost anyone has achieved and cost is the total cost of the comparisons you make (so your score for a test case will be between 0 and 1). Your score for the problem will simply be the sum of your scores for the individual test cases.
標(biāo)簽:
represented
integers
group
items
上傳時間:
2016-01-17
上傳用戶:jeffery
-
實(shí)驗(yàn)源代碼
//Warshall.cpp #include<stdio.h> void warshall(int k,int n) { int i , j, t; int temp[20][20]; for(int a=0;a<k;a++) { printf("請輸入矩陣第%d 行元素:",a); for(int b=0;b<n;b++) { scanf ("%d",&temp[a][b]); } } for(i=0;i<k;i++){ for( j=0;j<k;j++){ if(temp[ j][i]==1) { for(t=0;t<n;t++) { temp[ j][t]=temp[i][t]||temp[ j][t]; } } } } printf("可傳遞閉包關(guān)系矩陣是:\n"); for(i=0;i<k;i++) { for( j=0;j<n;j++) { printf("%d", temp[i][ j]); } printf("\n"); } } void main() { printf("利用 Warshall 算法求二元關(guān)系的可傳遞閉包\n"); void warshall(int,int); int k , n; printf("請輸入矩陣的行數(shù) i: "); scanf("%d",&k);
四川大學(xué)實(shí)驗(yàn)報告 printf("請輸入矩陣的列數(shù) j: "); scanf("%d",&n); warshall(k,n); }
標(biāo)簽:
warshall
離散
實(shí)驗(yàn)
上傳時間:
2016-06-27
上傳用戶:梁雪文以
-
#include "iostream" using namespace std;
class Matrix
{
private:
double** A; //矩陣A
double *b; //向量b
public:
int size;
Matrix(int );
~Matrix();
friend double* Dooli(Matrix& );
void Input();
void Disp();
};
Matrix::Matrix(int x) {
size=x;
//為向量b分配空間并初始化為0
b=new double [x];
for(int j=0;j<x;j++)
b[j]=0;
//為向量A分配空間并初始化為0
A=new double* [x];
for(int i=0;i<x;i++)
A[i]=new double [x];
for(int m=0;m<x;m++)
for(int n=0;n<x;n++)
A[m][n]=0;
}
Matrix::~Matrix() {
cout<<"正在析構(gòu)中~~~~"<<endl;
delete b;
for(int i=0;i<size;i++)
delete A[i];
delete A;
}
void Matrix::Disp()
{
for(int i=0;i<size;i++)
{
for(int j=0;j<size;j++)
cout<<A[i][j]<<" ";
cout<<endl;
}
}
void Matrix::Input()
{
cout<<"請輸入A:"<<endl;
for(int i=0;i<size;i++)
for(int j=0;j<size;j++){
cout<<"第"<<i+1<<"行"<<"第"<<j+1<<"列:"<<endl;
cin>>A[i][j];
}
cout<<"請輸入b:"<<endl;
for(int j=0;j<size;j++){
cout<<"第"<<j+1<<"個:"<<endl;
cin>>b[j];
}
}
double* Dooli(Matrix& A) {
double *Xn=new double [A.size];
Matrix L(A.size),U(A.size);
//分別求得U,L的第一行與第一列
for(int i=0;i<A.size;i++)
U.A[0][i]=A.A[0][i];
for(int j=1;j<A.size;j++)
L.A[j][0]=A.A[j][0]/U.A[0][0];
//分別求得U,L的第r行,第r列
double temp1=0,temp2=0;
for(int r=1;r<A.size;r++){
//U
for(int i=r;i<A.size;i++){
for(int k=0;k<r-1;k++)
temp1=temp1+L.A[r][k]*U.A[k][i];
U.A[r][i]=A.A[r][i]-temp1;
}
//L
for(int i=r+1;i<A.size;i++){
for(int k=0;k<r-1;k++)
temp2=temp2+L.A[i][k]*U.A[k][r];
L.A[i][r]=(A.A[i][r]-temp2)/U.A[r][r];
}
}
cout<<"計算U得:"<<endl;
U.Disp();
cout<<"計算L的:"<<endl;
L.Disp();
double *Y=new double [A.size];
Y[0]=A.b[0];
for(int i=1;i<A.size;i++ ){
double temp3=0;
for(int k=0;k<i-1;k++)
temp3=temp3+L.A[i][k]*Y[k];
Y[i]=A.b[i]-temp3;
}
Xn[A.size-1]=Y[A.size-1]/U.A[A.size-1][A.size-1];
for(int i=A.size-1;i>=0;i--){
double temp4=0;
for(int k=i+1;k<A.size;k++)
temp4=temp4+U.A[i][k]*Xn[k];
Xn[i]=(Y[i]-temp4)/U.A[i][i];
}
return Xn;
}
int main()
{
Matrix B(4);
B.Input();
double *X;
X=Dooli(B);
cout<<"~~~~解得:"<<endl;
for(int i=0;i<B.size;i++)
cout<<"X["<<i<<"]:"<<X[i]<<" ";
cout<<endl<<"呵呵呵呵呵";
return 0;
}
標(biāo)簽:
道理特分解法
上傳時間:
2018-05-20
上傳用戶:Aa123456789
-
非均勻有理b樣條曲線nurbs的C++源碼庫。
3.0.11版
標(biāo)簽:
nurbs
11
源碼
上傳時間:
2015-04-24
上傳用戶:Miyuki
-
Haskell 中文教程1-3章(flw譯)
純粹的函數(shù)型編程語言。以著名邏輯學(xué)家 Haskell B. Curry 的名字命名。
最初的目的是想要設(shè)計出滿足下面這些要求的語言:
1,它必須能夠適合教學(xué)、研究、應(yīng)用開發(fā),包括一些大系統(tǒng)的構(gòu)造。
2,它必須能夠使用形式語言來準(zhǔn)確描述。
3,它必須是自由免費(fèi)的,任何人只要愿意都可以獲取、使用和再次發(fā)布它。
4,它必須建立在大家一致認(rèn)可的基礎(chǔ)上。
5,它應(yīng)該能夠消除目前的函數(shù)型編程語言的差異。
標(biāo)簽:
Haskell
B.
Curry
flw
上傳時間:
2014-01-10
上傳用戶:685
-
Delphi2005 BS程序設(shè)計技巧集 (1-3)
現(xiàn)在delphi 2005 B/S的書籍資料太少,幾乎沒有可參考的資料,這在一定程度上限制了delphi 2005的使用,相反C#,ASP的書籍資料到處都是。通過幾個月的學(xué)習(xí)也算是總結(jié)了一點(diǎn)經(jīng)驗(yàn),從現(xiàn)在起我將陸續(xù)將ASP和C#的例子、技巧翻譯到delphi 2005下面,希望對大家的學(xué)習(xí)和工作有幫助,畢竟.Net是一種發(fā)展趨勢。我將不定期寫新的內(nèi)容,同時,如果你在工作或?qū)W習(xí)中有什么問題,我也會將問題加入本篇文章,另外,一個人的能力畢竟有限,也希望大家共同來解決問題。
宋雨炫
標(biāo)簽:
2005
Delphi
delphi
程序
上傳時間:
2013-11-25
上傳用戶:lgnf
-
車牌定位---VC++源代碼程序
1.24位真彩色->256色灰度圖。
2.預(yù)處理:中值濾波。
3.二值化:用一個初始閾值T對圖像A進(jìn)行二值化得到二值化圖像B。
初始閾值T的確定方法是:選擇閾值T=Gmax-(Gmax-Gmin)/3,Gmax和Gmin分別是最高、最低灰度值。
該閾值對不同牌照有一定的適應(yīng)性,能夠保證背景基本被置為0,以突出牌照區(qū)域。
4.削弱背景干擾。對圖像B做簡單的相鄰像素灰度值相減,得到新的圖像G,即Gi,j=|Pi,j-Pi,j-1|i=0,1,…,439 j=0,1,…,639Gi,0=Pi,0,左邊緣直接賦值,不會影響整體效果。
5.用自定義模板進(jìn)行中值濾波
區(qū)域灰度基本被賦值為0。考慮到文字是由許多短豎線組成,而背景噪聲有一大部分是孤立噪聲,用模板(1,1,1,1,1)T對G進(jìn)行中值濾波,能夠得到除掉了大部分干擾的圖像C。
6.牌照搜索:利用水平投影法檢測車牌水平位置,利用垂直投影法檢測車牌垂直位置。
7.區(qū)域裁剪,截取車牌圖像。
標(biāo)簽:
1.24
256
圖像
閾值
上傳時間:
2013-11-26
上傳用戶:懶龍1988