CCF全国信息学奥林匹克联赛(NOIP2013)复赛题目百分解
pascal吧
全部回复
仅看楼主
level 6
ijpoj 楼主
第一题:计数问题.
program count;
var
n,i,m,t:longint;
begin
assign(input,'count.in');
reset(input);
assign(output,'count.out');
rewrite(output);
readln(n,m);
t:=0;
for i:=1 to n do begin
if (i>=0)and(i<=9) then begin
if i=m then inc(t);
end;
if (i>=10)and(i<=99) then begin
if i div 10 = m then inc(t);
if i mod 10 = m then inc(t);
end;
if (i>=100)and(i<=999) then begin
if i div 100 = m then inc(t);
if i div 10 mod 10 = m then inc(t);
if i mod 10 = m then inc(t);
end;
if (i>=1000)and(i<=9999) then begin
if i div 1000 = m then inc(t);
if i div 100 mod 10 = m then inc(t);
if i div 10 mod 10 = m then inc(t);
if i mod 10 = m then inc(t);
end;
if (i>=10000)and(i<=99999) then begin
if i div 10000 = m then inc(t);
if i div 1000 mod 10 = m then inc(t);
if i div 100 mod 10 = m then inc(t);
if i div 10 mod 10 = m then inc(t);
if i mod 10 = m then inc(t);
end;
if (i>=100000)and(i<=999999) then begin
if i div 100000 = m then inc(t);
if i div 10000 mod 10 = m then inc(t);
if i div 1000 mod 10 = m then inc(t);
if i div 100 mod 10 = m then inc(t);
if i div 10 mod 10 = m then inc(t);
if i mod 10 = m then inc(t);
end;
if (i>=1000000)and(i<=9999999) then begin
if i div 1000000 = m then inc(t);
if i div 100000 mod 10 = m then inc(t);
if i div 10000 mod 10 = m then inc(t);
if i div 1000 mod 10 = m then inc(t);
if i div 100 mod 10 = m then inc(t);
if i div 10 mod 10 = m then inc(t);
if i mod 10 = m then inc(t);
end;
end;
writeln(t);
close(input);
close(output);
end.
2013年11月19日 05点11分 1
level 6
ijpoj 楼主
二楼提问
2013年11月19日 05点11分 2
大家也可给我百分解
2013年11月19日 05点11分
level 8
var i,n,o,tot:longint;
s,x:string;
begin
assign(input,'count.in');reset(input);
assign(output,'count.out');rewrite(output);
readln(n,x);
delete(x,1,1);
for i:=1 to n do begin
str(i,s);
for o:=1 to length(s) do if s[o]=x then inc(tot);
end;
writeln(tot);
close(input);close(output);
end.
你那是绝对的新手方法
2013年11月19日 08点11分 3
求解释delete(x,1,1);新手问问
2014年10月05日 11点10分
回复 TVXQ豆花天道 :从字符串x的第1位开始删,删一位。
2014年12月04日 13点12分
为什么我把你的复制进去会出现exited with exitcode=2 呐??
2015年11月07日 02点11分
@菩萨蛮中讲道人X 这洛阳铲。。这是文件操作,就是那个assign那两行,大多数评测都要文件操作。删掉就不会错误2了
2015年11月08日 09点11分
level 7
orz LZ
2013年11月20日 05点11分 4
level 8
orz
2013年11月20日 07点11分 5
level 11
第一题根本就不用这么麻烦,模拟满分!
2013年11月20日 11点11分 6
level 14
program expr(input,output);
var n,a,b:longint;ch:char;
begin
assign(input,'expr.in');
reset(input);
assign(output,'expr.out');
rewrite(output);
a:=0;
n:=0;
b:=1;
while not(eoln) do
begin
read(ch);
if ch='+' then
begin
b:=(b*n) mod 10000;
n:=0;
a:=(a+b) mod 10000;
b:=1;
continue;
end;
if ch='*' then
begin
b:=(b*n) mod 10000;
n:=0;
continue;
end;
n:=(n*10+ord(ch)-48) mod 10000;
end;
b:=(b*n) mod 10000;
a:=(a+b) mod 10000;
writeln(a);
writeln();
close(input);
close(output);
end.
2013年11月20日 11点11分 7
真棒
2013年11月22日 10点11分
level 14
program count(input,output);
var n,i,j:longint;x:integer;st:string;total:longint;
begin
assign(input,'count.in');
reset(input);
assign(output,'count.out');
rewrite(output);
readln(n,x);
total:=0;
for i:=1 to n do
begin
str(i,st);
for j:=1 to length(st) do
if st[j]=chr(x+48) then
inc(total);
end;
writeln(total);
writeln();
close(input);
close(output);
end.
2013年11月20日 11点11分 8
+1 谢谢你啊!
2013年11月22日 10点11分
倒数第四行是怎么回事?
2013年11月22日 10点11分
回复 ijpoj :我们老师说,为防止Linux下出问题,结尾多打一个回车总没错的。
2013年11月22日 10点11分
level 7

       ✎   灵失空间,我给你留下了这么一句话。
2013年11月20日 14点11分 9
level 8
求教第二题解题思路,这里程序看不懂呐~
2013年11月22日 08点11分 10
level 1
这位是不会使用循环吧!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2014年10月09日 15点10分 11
level 5
for i:=1 to n do
begin
t:=i;
while i>0 do
begin
if i mod 10=m then inc(tot);
i:=i div 10;
end;
end;
writeln(tot);
2014年10月10日 04点10分 12
抱歉,while循环下所有的i应更正为t
2014年10月10日 04点10分
1