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
标签: government streamline important alphabet
上传时间: 2015-06-09
上传用户:weixiao99
LCS(最长公共子序列)问题可以简单地描述如下: 一个给定序列的子序列是在该序列中删去若干元素后得到的序列。给定两个序列X和Y,当另一序列Z既是X的子序列又是Y的子序列时,称Z是序列X和Y的公共子序列。例如,若X={A,B,C,B,D,B,A},Y={B,D,C,A,B,A},则序列{B,C,A}是X和Y的一个公共子序列,但它不是X和Y的一个最长公共子序列。序列{B,C,B,A}也是X和Y的一个公共子序列,它的长度为4,而且它是X和Y的一个最长公共子序列,因为X和Y没有长度大于4的公共子序列。 最长公共子序列问题就是给定两个序列X={x1,x2,...xm}和Y={y1,y2,...yn},找出X和Y的一个最长公共子序列。对于这个问题比较容易想到的算法是穷举,对X的所有子序列,检查它是否也是Y的子序列,从而确定它是否为X和Y的公共子序列,并且在检查过程中记录最长的公共子序列。X的所有子序列都检查过后即可求出X和Y的最长公共子序列。X的每个子序列相应于下标集{1,2,...,m}的一个子集。因此,共有2^m个不同子序列,从而穷举搜索法需要指数时间。
上传时间: 2015-06-09
上传用户:气温达上千万的
三相步进电机的三相六拍工作方式,正转的绕组通电顺序:A、AB、B、BC、C、CA、A,反转的通电顺序:A、AC、C、CB、B、BA、B、A。 由于步进电机转子有一定的惯性以及所带负载的惯性,故步进电机的工作过程中不能及时的启动和停止,在启动时应慢慢的加速到预定速度,在停止前应逐渐减速到停止,否则,将产生失步现象。 步进电机的控制问题可总结为两点: 1、产生工作方式需要的时序脉冲; 2、控制步进电机的速度,使它始终遵循加速、匀速、减速的规律工作。
上传时间: 2015-12-01
上传用户:685
学会对文件的记录锁定,及解锁。#include <stdio.h> #include <unistd.h> #include <fcntl.h> int main() { int fd int i struct { char name[20] uint ID int age } myrec fd =open("name", O_RDWR|O_CREAT, 0755) if (fd == -1) return -1 printf("Input your name:") scanf("%s", myrec.name) printf("Inpute your ID :") scanf("%d", &myrec.ID) printf("Input your age :") scanf("%d", &myrec.age) lseek(fd, 0,SEEK_END) lockf(fd, 1, 0) write(fd, (void *)&myrec, sizeof(myrec)) lockf(fd, 0 ,0) return 0 } 执行命令cc lock.c –o lock.out Chmod +x lock.out ./lock.out
标签: 记录
上传时间: 2016-01-04
上传用户:亚亚娟娟123
Tornado 的manuals 很全面,国内的书大部分是翻译的它。经常需要查阅的。Tornado Online Manuals GDB User s Guide GNU Make User s Guide GNU Toolchain Release Notes GNU Toolkit User s Guide for Pentium GNU Toolkit User s Guide for Simulators, 68K, and SH Tornado API Guide Tornado API Reference Tornado Getting Started Guide (Windows Version) Tornado Migration Guide Tornado Reference Tornado Release Notes Tornado SETUP SDK Developer s Guide Tornado User s Guide (Windows Version) USB Developer s Kit Programmer s Guide USB Developer s Kit Release Notes VxWorks API Reference VxWorks BSP Developer s Guide VxWorks BSP Developer s Reference VxWorks BSP Reference VxWorks Errno Code List VxWorks Network Programmer s Guide VxWorks Programmer s Guide VxWorks for Pentium Architecture Supplement WindView User s Guide WindView User s Reference
标签: Tornado Manuals manuals Online
上传时间: 2016-05-16
上传用户:13215175592
Digital Signature Algorithm (DSA)是Schnorr和ElGamal签名算法的变种,被美国NIST作为DSS(DigitalSignature Standard)。算法中应用了下述参数: p:L bits长的素数。L是64的倍数,范围是512到1024; q:p - 1的160bits的素因子; g:g = h^((p-1)/q) mod p,h满足h < p - 1, h^((p-1)/q) mod p > 1; x:x < q,x为私钥 ; y:y = g^x mod p ,( p, q, g, y )为公钥; H( x ):One-Way Hash函数。DSS中选用SHA( Secure Hash Algorithm )。 p, q, g可由一组用户共享,但在实际应用中,使用公共模数可能会带来一定的威胁。签名及验证协议如下: 1. P产生随机数k,k < q; 2. P计算 r = ( g^k mod p ) mod q s = ( k^(-1) (H(m) + xr)) mod q 签名结果是( m, r, s )。 3. 验证时计算 w = s^(-1)mod q u1 = ( H( m ) * w ) mod q u2 = ( r * w ) mod q v = (( g^u1 * y^u2 ) mod p ) mod q 若v = r,则认为签名有效。 DSA是基于整数有限域离散对数难题的,其安全性与RSA相比差不多。DSA的一个重要特点是两个素数公开,这样,当使用别人的p和q时,即使不知道私钥,你也能确认它们是否是随机产生的,还是作了手脚。RSA算法却作不到。
标签: Algorithm Signature Digital Schnorr
上传时间: 2014-01-01
上传用户:qq521
利用伟福 Lab2000P单片机实验仪上提供的显示电路和键盘电路,做一个简单的计算器。用十六进制A键 =‘+’、B键 =‘-’、C键 = ‘x’、D键 = ‘/’、E键 = ‘=’、F键 = ‘C’。
上传时间: 2016-08-22
上传用户:ukuk
This utility has two views: (a) one view that will show you the entire PnP enumeration tree of device objects, including relationships among objects and all the device s reported PnP characteristics, and (b) a second view that shows you the device objects created, sorted by driver name. There is nothing like this utility available anywhere else.
标签: enumeration utility entire devic
上传时间: 2013-12-17
上传用户:zjf3110
程序是根据vidcat改的,只能抓PPM的图. makefile的内容如下,请注意打小写: cc=gcc #cflags=-i/firendly-arm/kernel/include -i/usr/local/arm/2.95.3/arm-linux/include -wall -dhave_libjpeg #-dvideo_dev=\"/dev/v4l/video0\" -dversion=\"0.7.2\" cflags=-wall -dvideo_dev=\"/dev/video0\" -dversion=\"0.7.2\" camsnap: camsnap.c 用法如下: camsnap -v -s 420x420 -o my.ppm 这儿请注意:s 的大小必需是8能整除的倍数. 这个程序我是在rh9下作的,需要交叉编译的朋友就把注释去掉,再给下面的注释就可以了.
标签: firendly-arm makefile include vidcat
上传时间: 2016-11-20
上传用户:清风冷雨
function [U,center,result,w,obj_fcn]= fenlei(data) [data_n,in_n] = size(data) m= 2 % Exponent for U max_iter = 100 % Max. iteration min_impro =1e-5 % Min. improvement c=3 [center, U, obj_fcn] = fcm(data, c) for i=1:max_iter if F(U)>0.98 break else w_new=eye(in_n,in_n) center1=sum(center)/c a=center1(1)./center1 deta=center-center1(ones(c,1),:) w=sqrt(sum(deta.^2)).*a for j=1:in_n w_new(j,j)=w(j) end data1=data*w_new [center, U, obj_fcn] = fcm(data1, c) center=center./w(ones(c,1),:) obj_fcn=obj_fcn/sum(w.^2) end end display(i) result=zeros(1,data_n) U_=max(U) for i=1:data_n for j=1:c if U(j,i)==U_(i) result(i)=j continue end end end
标签: data function Exponent obj_fcn
上传时间: 2013-12-18
上传用户:ynzfm