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
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.
标签: represented integers group items
上传时间: 2016-01-17
上传用户:jeffery
Generate 100 samples of a zero-mean white noise sequence with variance , by using a uniform random number generator. a Compute the autocorrelation of for . b Compute the periodogram estimate and plot it. c Generate 10 different realizations of , and compute the corresponding sample autocorrelation sequences , and . Compute the average autocorrelation sequence as and the corresponding periodogram for . d Compute and plot the average periodogram using the Bartlett method. e Comment on the results in parts (a) through (d).
标签: zero-mean Generate sequence variance
上传时间: 2016-03-04
上传用户:朗朗乾坤
Use the fast Fourier transform function fft to analyse following signal. Plot the original signal, and the magnitude of its spectrum linearly and logarithmically. Apply Hamming window to reduce the leakage. . The hamming window can be coded in Matlab as for n=1:N hamming(n)=0.54+0.46*cos((2*n-N+1)*pi/N); end; where N is the data length in the FFT.
标签: matlab fft
上传时间: 2015-11-23
上传用户:石灰岩123
实验源代码 //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("可传递闭包关系矩阵是:\n"); for(i=0;i<k;i++) { for( j=0;j<n;j++) { printf("%d", temp[i][ j]); } printf("\n"); } } void main() { printf("利用 Warshall 算法求二元关系的可传递闭包\n"); void warshall(int,int); int k , n; printf("请输入矩阵的行数 i: "); scanf("%d",&k); 四川大学实验报告 printf("请输入矩阵的列数 j: "); scanf("%d",&n); warshall(k,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<<"正在析构中~~~~"<<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; }
标签: 道理特分解法
上传时间: 2018-05-20
上传用户:Aa123456789
function [R,k,b] = msc(A) % 多元散射校正 % 输入待处理矩阵,通过多元散射校正,求得校正后的矩阵 %% 获得矩阵行列数 [m,n] = size(A); %% 求平均光谱 M = mean(A,2); %% 利用最小二乘法求每一列的斜率k和截距b for i = 1:n a = polyfit(M,A(:,i),1); if i == 1 k = a(1); b = a(2); else k = [k,a(1)]; b = [b,a(2)]; end end %% 求得结果 for i = 1:n Ai = (A(:,i)-b(i))/k(i); if i == 1 R = Ai; else R = [R,Ai]; end end
上传时间: 2020-03-12
上传用户:15275387185
对PL/0作以下修改和扩充,并使用测试用例验证: (1)修改单词:不等号# 改为 != ,只有!符号为非法单词,同时#成为非法 符号。 (2)增加单词(只实现词法分析部分): 保留字 ELSE,FOR,STEP,UNTIL,DO,RETURN 运算符 *=(TIMESBECOMES),/=(SLASHBECOMES),&(AND),||(OR) 注释符 //(NOTE) (3)增加条件语句的ELSE子句(实现语法语义目标代码), 要求:写出相关文法和语法图,分析语义规则的实现。
上传时间: 2020-06-30
上传用户:12345a
特点: 精确度0.1%满刻度 可作各式數學演算式功能如:A+B/A-B/AxB/A/B/A&B(Hi or Lo)/|A|/ 16 BIT类比输出功能 输入与输出绝缘耐压2仟伏特/1分钟(input/output/power) 宽范围交直流兩用電源設計 尺寸小,穩定性高
上传时间: 2014-12-23
上传用户:ydd3625
开关在电路中起接通信号或断开信号的作用。最常见的可控开关是继电器,当给驱动继电器的驱动电路加高电平或低电平时,继电器就吸合或释放,其触点接通或断开电路。CMOS模拟开关是一种可控开关,它不象继电器那样可以用在大电流、高电压场合,只适于处理幅度不超过其工作电压、电流较小的模拟或数字信号。 一、常用CMOS模拟开关引脚功能和工作原理 1.四双向模拟开关CD4066 CD4066 的引脚功能如图1所示。每个封装内部有4个独立的模拟开关,每个模拟开关有输入、输出、控制三个端子,其中输入端和输出端可互换。当控制端加高电平时,开关导通;当控制端加低电平时开关截止。模拟开关导通时,导通电阻为几十欧姆;模拟开关截止时,呈现很高的阻抗,可以看成为开路。模拟开关可传输数字信号和模拟信号,可传输的模拟信号的上限频率为40MHz。各开关间的串扰很小,典型值为-50dB。
上传时间: 2013-10-27
上传用户:bibirnovis