第一范文网 - 专业文章范例文档资料分享平台

NOIP2013初赛提高组Pascal试题及答案 

来源:用户分享 时间:2025/5/14 23:10:03 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

j := 1; //i, j 分别表示当前子序列的首尾,并保证其中至多有两个不同整数

while (j <= n) and (a[j] = a[i]) do

inc(j); cur1 := a[i];

cur2 := a[j]; count1 := (1) ; count2 := 1; ans_length := j - i + 1;

while j < n do begin

inc(j);

if a[j] = cur1 then

inc(count1)

else if a[j] = cur2 then

inc(count2) else begin

if a[j - 1] = (2) then

begin

while count2 > 0 do begin

if a[i] = cur1 then

dec(count1) else

dec(count2); inc(i);

end;

cur2 := a[j];

count2 := 1;

end

else begin

while count1 > 0 do begin

if a[i] = cur1 then

(3) else

(4) ; CCF NOIP2013 初赛提高组 Pascal 语言试题第 11 页,共 12 页

//(3 分)

//(3 分)

//(2 分) //(2 分)

inc(i);

end;

(5)

; //(3 分)

count1 := 1; end; end;

if (ans_length < j - i + 1) then begin

ans_length := j - i + 1;

ans_start := i;

ans_end := j;

end;

end;

for i := ans_start to ans_end do

write(a[i], ' ');

end.

CCF NOIP2013 初赛提高组 Pascal 语言试题

第 12 页,共 12 页

NOIP2013 初赛提高组(Pascal语言)试题参考解答

一、单项选择

1 A 2 A 3 B 4 D 5 A 6 B 7 D 8 B 9 D 10 11 12 13 14 15 D C B D B B 二、多项选择

1 AC 三、解答题

1. 0 1 1 1 2. 37/12 求解方法为:

2 AD 3 CD 4 AB 5 ABCD 先将问题转为青蛙随机跳了一步以后的情况,分为5种情况,分别是落在1号、2号、3号、4号、5号荷叶上,于是有 f5=(f1 + 1+f2+ 1+f3+ 1+f4 +1+f5) / 5 ,从而推得 f5=1+(f1+f2+f3+f4)/4。

推而广之,求fn的递推式为: f[1]=1

f[n]=1+(f[1]+f[2]+…+f[n-1])/(n-1) (n>1) 四、阅读程序题

(1)Yes 判定输入的字符串是否是回文串

(2)133 1到1000中是10或15的倍数的数的个数 (3)4 最长上升子序列的长度 (4)7 图中最长通路的长度 五、完成程序题

1.(1) n+i-p (2) i+1-p (3) a[i-p] (4) j<=end2 (5) i (6) J-1(或start2-1) 2、(1)j-1 (2) cur1 (3) dec(count1) (4) dec(count2) (5) cur1:=a[j]

CCF NOIP2013 初赛提高组 Pascal 语言试题

第 13 页,共 12 页

搜索更多关于: NOIP2013初赛提高组Pascal试题及答案  的文档
NOIP2013初赛提高组Pascal试题及答案 .doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c1cj7p4krcj9gaia4885k_3.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top