资源描述:
《tyvj__部分题解代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、p1008varf:array[1..100,0..100]oflongint;i,k,m,n,j:longint;beginread(n,m);f[1,1]:=0;f[1,2]:=1;f[1,0]:=1;fori:=2tomdoforj:=0ton-1dof[i,j]:=f[i-1,(j-1+n)modn]+f[i-1,(j+1)modn];write(f[m,1]);end.P1014usesmath;varf:array[1..100,1..100]oflongint;i,j,k,m,n,p,min1
2、:longint;head,tail:array[1..100]oflongint;beginread(n);min1:=maxlongint;fori:=1tondoread(head[i]);fori:=1ton-1dotail[i]:=head[i+1];tail[n]:=head[1];{fori:=n+1to2*n-1doBeginhead[i]:=head[i-n];tail[i]:=tail[i-n];end;}forp:=1ton-1dofori:=1ton-1dobeginj:=p+i;i
3、fj>nthenbreak;fork:=itoj-1doiff[i,j]<>0thenf[i,j]:=min(f[i,j],f[i,k]+f[k+1,j]+head[i]*tail[k]*tail[j])elsef[i,j]:=max(f[i,j],f[i,k]+f[k+1,j]+head[i]*tail[k]*tail[j]);end;write(f[1,n-1]);end.P1024usesmath;vara:array['a'..'z']ofinteger;i,j,k,m,n:longint;s0:s
4、tring;s:array[1..1000]ofstring;procedureinit;vari,j:longint;beginfori:=1tolength(s0)doa[s0[i]]:=i;end;procedureqq;vari,j:longint;begink:=1;fori:=1tolength(s0)dobeginifs0[i]<>''thens[k]:=s[k]+s0[i];ifs0[i]=''theninc(k);end;end;proceduredfs(i:longint);vark,i
5、i,jj,l,max1:longint;b,f:array[1..1000]ofinteger;beginfillchar(f,sizeof(f),0);fillchar(b,sizeof(b),0);max1:=0;forii:=1tolength(s[i])dob[ii]:=a[s[i][ii]];l:=length(s[i]);forii:=1toldof[ii]:=1;forii:=1toldoforjj:=ii+1toldobeginifb[jj]>=b[ii]thenf[jj]:=max(f[j
6、j],f[ii]+1);end;forii:=1toldomax1:=max(max1,f[ii]);write(max1);end;beginassign(input,'aa.in');reset(input);readln(s0);init;readln(s0);qq;fori:=1tokdodfs(i);end.P1029usesmath;vars0,s1:string;i,j,k,m,n,max1:longint;functioncheck(s0,s1:string;i,l0,l1:longint)
7、:longint;varj,k,tt:longint;begink:=1;tt:=0;forj:=itol1dobeginifs1[j]=s0[k]thenbegininc(tt);inc(k);endelseifs1[j]<>s0[k]thenbegincheck:=tt;exit;end;end;check:=tt;end;proceduredfs(s0,s1:string);vari,j,k,l1,l0:longint;beginl0:=length(s0);l1:=length(s1);fori:=
8、l1downto1doifs1[i]=s0[1]thenmax1:=max(max1,check(s0,s1,i,l0,l1));beginreadln(s0);readln(s1);dfs(s0,s1);dfs(s1,s0);write(max1);end.P1045usesmath;vara,k:array[0..15]oflongint;f:array[1..15]ofboolean;s:array[0..